Here is a quick guide to optimize php ini for Rackspace Cloud Server (PVHVM) for higher performance and lower page loading speed. We talked about PVHVM Virtualization Mode. You probably know about guides on APC Configuration and Optimization for Rackspace Cloud Server (PVHVM), Rackspace Cloud Database, Install APC, Tweak MySQL my.cnf, use Varnish Cache etc. Also, you can read Memcached Configuration and Optimization for Rackspace Cloud Server.
Also, it is suggested to read Hardening Rackspace Cloud Server for WordPress. Last but the most important remaining is Optimize php ini for Rackspace Cloud Server (PVHVM).
Optimize php ini for Rackspace Cloud Server (PVHVM) : Basics
It is funny, but there are many unknown sources to optimize php ini file, for example; by Apple Inc :
http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-4.3/php/php.ini-optimized?txt
On Linux, for normal LAMP server installation; php.ini file is located at :
---
1 | /etc/php5/apache2 |
To find php.ini, we need to run :
1 | php --ini |
You will get this kind of output :
1 2 3 4 5 6 7 8 9 10 | Configuration File (php.ini) Path: /etc/php5/cli Loaded Configuration File: /etc/php5/cli/php.ini Scan for additional .ini files in: /etc/php5/cli/conf.d Additional .ini files parsed: /etc/php5/cli/conf.d/curl.ini, /etc/php5/cli/conf.d/pdo.ini, /etc/php5/cli/conf.d/pdo_sqlite.ini, /etc/php5/cli/conf.d/sqlite.ini, /etc/php5/cli/conf.d/sqlite3.ini, /etc/php5/cli/conf.d/xdebug.ini, /etc/php5/cli/conf.d/xsl.ini |
Like, we ran the command on our Mac running OS X 10.9 :
Also, you can run a simple command :
1 | php -i | grep 'php.ini' |
It will only give you the output of the location :
1 | Loaded Configuration File => /usr/local/lib/php.ini |
For PHP-MySQL based web softwares like WordPress, editing this php.ini
wrongly can fully make the system unstable. So, always read the documentation from official website first to know the function. Take a backup of the file (its quite bigger) via FTP client like Filezilla, edit a copied version on plain text editor locally and replace it via FTP, in case you are not used with command line. If you are logging to FTP as root, binary transfer mode has no difference than editing on nono on command line. Plus, FTP way will allow to keep the original file as backup by renaming – very easy to restore. If you edit wrongly, running the grep command with -i flag might show up :
1 2 | Configuration File (php.ini) Path /etc/php5/apache2 Loaded Configuration File /etc/php5/apache2/php.ini |
It simply means your configuration is not read. A syntax error in php.ini
in line numbered x, will render next all the syntax not excite.
We should restart the Apache after editing :
1 | sudo service apache2 restart |
Do not edit on FTP client like Filezilla in all cases, it is a handy tip for testing settings for huge changes.php.ini
can make a site load quite badly or can make it fully optimized. If you create a php file with this :
1 2 3 4 | <!--?php // Show all php information phpinfo(); ?--> |
and load the file on browser, you will get all the information. Also, if you want a crazy nice script, you can download it from this article to get maximum possible information about php.
Also, this file determines the maximum uploading size like basic functions. Official documentation :
1 | http://www.php.net/manual/en/configuration.file.php |
Optimize php ini for Rackspace Cloud Server (PVHVM) : Things
This an universal suggested php.ini configuration to optimize php.ini for one 01 GB server instance (we are taking that MySQL server is not on the same host, if on the same host, adjust according to load value, setting memory to ¼th is safer, ;; or ; are comments) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | memory_limit = 512M max_execution_time = 360 max_input_time = 900 post_max_size = 50M upload_max_filesize = 900M ;; more here realpath_cache_size = 64k realpath_cache_ttl = 3600 ;; ; Allow files to be uploaded file_uploads = On ; Allow external URLs to be opened allow_url_fopen = On ; Disable PHP register globals register_globals = Off ; Enable GZIP compression at the default level zlib.output_compression = On zlib.output_compression_level = 6 ; Load mcrypt extension extension=mcrypt.so ;; cookies using Mcrypt is faster than the Blowfish that is used by default ; Disable PHP magic quotes magic_quotes_gpc = Off magic_quotes_runtime = Off magic_quotes_sybase = Off ; Load PDO MySQL extension extension=pdo.so extension=pdo_mysql.so ;; zend path is not right, check yours zend_extension=/usr/local/.../xdebug.so xdebug.profiler_enable=1 xdebug.profiler_aggregate = On xdebug.profiler_output_dir=/tmp |
Editing parameters on /etc/php5/fpm/php.ini
will be the same in case php-fpm
is running. You probably should edit (for fpm) :
1 | /etc/php5/fpm/pool.d/ |
You need to fine tune PHP5-FPM with an example server with 1GB RAM. With12GB RAM, you can dedicate 700MB RAM for PHP and the rest for other processes if MySQL server is different. Now what files are there? for example; APC config :
1 | /etc/php5/conf.d/apc.ini |
We actually did that part on previous guides! At any time, you can test instantly your tweak by calling the functions.
Tagged With wordpress php ini optimization , optimization icloud com