PHP is the popular language for writing dynamic scripts. Blogging platforms like WordPress, Drupal and several other content management systems are written in PHP. Since we use WordPress we need to install PHP for the site to function.
Installing PHP
Use the following command to install PHP in Ubuntu.
[shell]sudo apt-get install php5 php-pear[/shell]
This will install PHP, to have MySQL support we need to install MySQL module. Use the following command to install php5 with MySQL
[shell]sudo apt-get install php5-mysql[/shell]
Suhosin is a protection system for PHP, that protects PHP application and core against bufferoverflows or format string vulnerabilities. Install Suhosin if you want to add security to PHP installation (Hardened PHP).
[shell]sudo apt-get install php5-suhosin[/shell]
If you plan to use PhpMyAdmin you may have to tweak Suhosin configuration by increasing the values of “suhosin.request.max.vars”.
Look for these settings in this file.
[shell]/etc/php5/conf.d/suhosin.ini[/shell]
You might want to change php.ini values like max_execution_time and memory_limit. use the following command to edit php.ini file
[shell]sudo nano /etc/php5/apache2/php.ini[/shell]
Save php.ini file and restart apache for the changes to take effect.
Installing APC
APC (Alternative PHP Cache) is a PHP accelerator, these extensions improve the performance of applications written in PHP. APC “optimizes PHP intermediate code and caches data and compiled code from the PHP bytecode compiler in shared memory.”
Enter the following commands to install APC
[shell]sudo apt-get install php-apc[/shell]
Restart Apache
[shell]sudo /etc/init.d/apache2 restart[/shell]
You have to edit apc.ini file and these lines, first line is must, others are optional. Depending on your blog size you can adjust the apc.shm_size value in the last line, if you have lot of traffic you can increase it to 64 or 100, this value stands for cache memory in MB allocated to APC..
[shell]extension=apc.so
apc.enabled=1
apc.shm_size=30[/shell]
Edit apc.ini file to add above values, use the following command
[shell]sudo nano /etc/php5/conf.d/apc.ini[/shell]
Restart Apache.
You might want to check if APC is installed by using phpinfo().
Other article in this series
Dedicated VPS Server with Linode
Installing Apache webserver on Ubuntu VPS
Useful .htaccess tips and tricks