Modifying the PHP Configuration
The php.ini
file can be edited to change the settings and configuration of how PHP functions. This section gives a few common examples.
Sometimes a PHP application might need to allow for larger upload files such as uploading themes and plugins on a WordPress site. To allow larger uploads for your PHP application, edit the php.ini
file with the following command (Change the path and file to match your Loaded Configuration File. This example shows the path for Apache on Ubuntu 14.04.):
1 |
- sudo nano /etc/php5/apache2/php.ini
1 |
The default lines that control the file size upload are:
1 2 3 |
post_max_size = 8M upload_max_filesize = 2M |
Change these default values to your desired maximum file upload size. For example, if you needed to upload a 30MB file you would changes these lines to:
1 2 3 |
post_max_size = <span class="highlight">30M</span> upload_max_filesize = <span class="highlight">30M</span> |
Other common resource settings include the amount of memory PHP can use as set by memory_limit
:
1 2 |
memory_limit = 128M |
or max_execution_time
, which defines how many seconds a PHP process can run for:
1 2 |
max_execution_time = 30 |
When you have the php.ini
file configured for your needs, save the changes, and exit the text editor.
Restart the web server to enable the changes. For Apache on Ubuntu 14.04, this command will restart the web server:
1 |
- sudo service apache2 restart
1 |
Refreshing the info.php
page should now show your updated settings. Remember to remove the info.php
when you are done changing your PHP configuration.
Leave a reply