PHP supports the following resource limits directives in php.ini file. To limit resources used by a PHP script edit the file php.ini. Note that this change will affect all websites and PHP scripts on the server.
To find the location of php.ini, you can use the phpinfo() PHP function to find it. Create file with following content:
<?php phpinfo(); ?>
To edit php.ini, type the following command:
[root@lifelinux ~]# vi /etc/usr/local/etc/php.ini
Set maximum execution time of each script:
max_execution_time = 30
Set maximum amount of time each script may spend parsing request data
max_input_time = 30
Set maximum amount of memory a script may consume
memory_limit = 64M
Set maximum size of POST data that PHP will accept
post_max_size = 8M
Set maximum allowed size for uploaded files
upload_max_filesize = 8M
Disable/Enable HTTP file uploads (Disallow uploading unless necessary)
file_uploads = Off
Final, restart web server, example restart apache server, type the following command
[root@lifelinux ~]# /etc/init.d/httpd restart
Related Posts:
- How To Install Lighttpd And PHP (PHP-FPM) On CentOS 6
- How Do I Configure Apache Server To Listen Multiple Ports ?
{ 1 trackback }
{ 2 comments… read them below or add one }
please let me know why you chose exact value for these parameter ?which value is acceptable for a server with low resources ?
Don’t have exact value for these parameters. In this article, I give the above values because it is compatible with most scripts and it is drawn from my experience.
For a server with low resources, you need to know your PHP program needs many resources to run. Example you are running Joomla then minimum 16MB memory allocated to php.