Tutorial: Configuring a LAMP stack

posted Jul 13, 2014, 11:47 PM by SRGICS UPLB   [ updated Jul 25, 2015, 9:10 PM ]
After following the User Guide, you are now ready to configure an instance to run Apache, MySQL, and PHP. Make sure that you are logged in to the instance (Step 9 of the User Guide)

1. Get a root shell
$sudo -s

2. Perform an update on the instance.
#apt-get update && apt-get -y upgrade

3. Install the standard packages for a LAMP Stack. Along the way you will be prompted to enter passwords for MySQL and PHPMyAdmin.
#apt-get install -y apache2 mysql-server php5 phpmyadmin proftpd

4. To test if your setup is successful open a web browser then type http://<floating IP Address of instance>/phpmyadmin on the address bar.

5. Next we need to optimize Apache and MySQL.
#nano /etc/apache2/apache.conf

Look for the mpm_prefork_module entry and replace it with the following. The entry below says to start with 10 processes with a maximum of 50 clients.
<IfModule mpm_prefork_module>
    ServerLimit           1000
    StartServers          10
    MinSpareServers       5
    MaxSpareServers       10
    MaxClients            50
    MaxRequestsPerChild   0
</IfModule>

Save the changes the restart Apache using the command below:
#/etc/init.d/apache2 restart

Next is to increase maximum concurrent connections for MySQL. Edit my.cnf
 
#nano /etc/mysql/my.cnf

Change the value for max_connections to, say, 300 (default is 100) then save the file. Restart MySQL using the command below:
#/etc/init.d/mysql restart