Where is my php ini file in mac?

Where is my php ini file in mac?

Where is my php ini file in mac?

If you are using Laravel Valet for local development on your Mac then you might need to change the php.ini configuration to suit your needs. It can be either increasing memory_limit, max_execution_time etc.

If you want to configure/setup Laravel Valet on Mac M1 then you can follow my previous article here.

Recently, I wrote an article about how to configure PHP Monitor which provides you the visual information about Laravel Valet and different configurations. It can also let you local PHP configuration file php.ini

By default all the PHP versions will be located in /usr/local/etc/php

Let's say, your current active version of PHP is 7.3 and you want to change the max_execution_time value. Go to the following location: /usr/local/etc/php/7.3

Here you will find php.ini file which is the main configuration file. But there is another file php-memory-limits.ini located inside the conf.d folder. By default this fill will have the following configuration:

; Max memory per instance
memory_limit = 512M

;The maximum size of an uploaded file.
upload_max_filesize = 512M

; Sets max size of post data allowed. 
; Changes to this will also need to be reflected in Nginx with client_max_body_size
; This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 512M

Enter fullscreen mode Exit fullscreen mode

which overrides the main php.ini file configurations.

For max_execution_time you can add it to this file with your desired value and the whole file will look like this:

; Max memory per instance
memory_limit = 512M

;The maximum size of an uploaded file.
upload_max_filesize = 512M

; Sets max size of post data allowed. 
; Changes to this will also need to be reflected in Nginx with client_max_body_size
; This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 512M

; Maximum execution time of each script, in seconds
; http://php.net/max-execution-time
; Note: This directive is hardcoded to 0 for the CLI SAPI
max_execution_time = 1800

Enter fullscreen mode Exit fullscreen mode

Restart the PHP and verify your changes.

Where is my php ini file in mac?

Last updated on June 7th, 2022 | 2 replies

As there are multiple versions of PHP with different sever configurations, php.ini could be located in several different folders.

Method 1

One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php.

info.php

Load this file in your browser, press CTRL + F (or Command + F on Mac) and search for “Loaded Configuration File”. You should see something like

/etc/php/8.1/apache2/php.ini

This will tell you the exact location of the php.ini file you want to edit.

Method 2

In Linux, run this command to locate the PHP.ini configuration file.

php -i | grep "Loaded Configuration File"

Or in Windows Command Line:

php -i | findstr /c:"Loaded Configuration File"

The result should be something like this:

Loaded Configuration File => /etc/php/8.1/cli/php.ini

In the above example, we can see that the PHP install is located in /etc/php/8.1. Note that there are three different configuration files you should we aware of:

CLI

/etc/php/8.1/cli/php.ini is for the CLI PHP program. Changes to this config file will only affect PHP as it runs in the terminal – it will NOT affect the web server.

Apache

/etc/php/8.1/apache2/php.ini is for the PHP plugin used by Apache. This is the one you need to edit if you are using the Apache web server.

Nginx or Apache with PHP-FPM

/etc/php/8.1/fpm/php.ini is a fastcgi-compatible ‘wrapper’ for PHP processing. This is the one you need to edit if you’re using the Nginx web server or Apache with PHP-FPM.

Method 3

Using the locate command in Linux,. If it’s not already installed, run  sudo apt update && sudo apt install mlocate.

You should see a list of php.ini files here. Try editing one of them and restarting you web server to see if makes the required changes.

Editing php.ini in Linux

Apache

On Apache, php.ini is usually located in /etc/php/8.1/apache2/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

To edit:

sudo nano /etc/php/8.1/apache2/php.ini

However, if you are using PHP FPM, it may be located in /etc/php/8.1/fpm/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

To edit:

sudo nano /etc/php/8.1/fpm/php.ini

To save file and exit, press CTRL + X, press Y and then press ENTER

You must restart Apache after altering php.ini.

sudo systemctl restart apache2

If you are using PHP-FPM, you must restart that service. Replace php8.1 with your own version, e.g, php5.6php7.4, etc.

sudo service php8.1-fpm restart

Nginx or Apache with PHP-FPM

Nginx uses PHP FPM and php.ini is usually located in /etc/php/8.1/fpm/php.ini. Replace 8.1 with your own version, e.g, php5.6php7.4, etc.

sudo nano /etc/php/8.1/fpm/php.ini

Save and exit (press CTRL + X, press Y and then press ENTER)

You must restart Nginx after altering php.ini.

sudo systemctl reload nginx

Older Versions

For versions of Ubuntu lower than 16.04, /etc/php/5.6/,/etc/php/7.0/,/etc/php/7.1/, and so on, are replaced by /etc/php5/ and so on. Otherwise, these paths remain accurate.

Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.

p.s. I increased my AdSense revenue by 200% using AI 🤖. Read my Ezoic review to find out how.

Where can I find PHP ini file?

Your answer.
You can get a full phpinfo() using : php -i..
And, in there, there is the php.ini file used : $ php -i | grep 'Configuration File' Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini..
On Windows use find instead: php -i|find/i"configuration file" Hope this is helpfull!!.

Where is PHP ini on Mac Catalina?

ini File at MacOS Catalina. For my MacOS Catalina, the location of php. ini is located at /etc/. As you can see there is no php.

Where is PHP ini file in xampp Mac?

ini file: Whenever we install PHP, we can locate the configuration file inside the PHP folder. If using xampp, we can find the configuration file in one or many versions, inside the path '\xampp\php'.

How do I open a PHP file on Mac?

Open the Finder and go to /Library/WebServer/Documents/localhost . All files that are in there are processed by the local webserver (Apache and PHP, if you want to know that). Place your file in there and open your webserver and call http://localhost/YourFile.php and it will call the file YourFile.