How do I access php.ini file?

I need to make a few changes in the php.ini file. Where can I find the file on the server?

5 Replies

Hello,

You can find your php.ini file by running the following command from your terminal window:

php -i | grep "Loaded Configuration File"

You may see something like:

PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
Loaded Configuration File => /etc/php.ini

The last line will show you were your php.ini file is: /etc/php.ini

The php.ini was located in out Linode:

dhd@jetchip:/etc/php/5.6$ php -i | grep "Loaded Configuration File"
Loaded Configuration File => /etc/php/5.6/cli/php.ini

The max_execution_time was increased to 180 and apache2 was restarted, but the new setting has not taken affect.

@jetchip --

You write:

dhd@jetchip:/etc/php/5.6$ php -i | grep "Loaded Configuration File"
Loaded Configuration File => /etc/php/5.6/cli/php.ini
 
The max_execution_time was increased to 180 and apache2 was restarted, but the new setting has not taken affect.

This configuration file is for the cli program /usr/bin/php…not anything apache2 would use. You need to look at one of the following:

/etc/php/5.6/fpm -> if you use the FastCGI process manager (php5.6-fpm)
/etc/php/5.6/apache2 -> if you use apache module (mod_php.so)

-- sw

P.S. Execution timeouts are almost always( ! ) indicative of defects in your code. Think very carefully about what you are doing. You may be making your problem worse.

I'n modified the max_execution time for each of the php.ini files mention, after restarting apache2, the error log is still showing:

"PHP Fatal error: Maximum execution time of 30 seconds exceeded"

When I run php -i | grep "max_execution", the output shows
"max_execution_time => 0 => 0"

That's why I wanted to make sure that I was making the setting change in the correct place.

Increasing the max_execution_time is a temporary fix, to keep the site from crashing until implement a code solution, which we are in the process of doing.

Thank you for your assistance.

@jetchip --

You write:

Increasing the max_execution_time is a temporary fix, to keep the site from crashing until implement a code solution, which we are in the process of doing.

If that's the case, increasing the max_execution_time is almost certainly guaranteed to fail to resolve your problem (https://www.php.net/manual/en/function.set-time-limit.php):

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct