Compression is particularly important on Amazon Web Services (AWS) because:
HTML is very redundant and bulky
Smaller files are sent to the client faster
AWS charges you based upon OUTPUT bandwidth; smaller files = less bandwidth usage per file
Simple activation of mod_deflate
These instructions assume you have already setup an AWS instance and have an SSH client (like PuTTY) available and a SCP client (like WinSCP) to use when editing the configuration files.
Log in to your instance via the SCP client then open the apache2 virtual hosts configuration file (“/etc/httpd/conf.d/vhosts.conf” for the default setup mentioned in other instructions here).
Add the “AddOutputFilterByType DEFLATE text/html text/plain text/xml” Filter to each virtual host (virtual hosts are the groupings starting with “<VirtualHost “). You should inclose the filter in a conditional module statement (“<IfModule xxxx.x>”) to make sure your web server keeps running even if you happen to remove the deflate module.
Save the virtual hosts configuration file.
Open the SSH client and transfer to the root user (“sudo su”)
Restart the apache2 service (“service httpd restart”).
The changes to the virtual hosts configuration file
Apache2 is the standard Linux web server. It deals with all of the http and https requests sent to the server and complies PHP scripts. PHP is a simpler programming language which offers the power of the more complex object orientated languages without some of the more complex data management issues. PHP is commonly used to develop dynamic web content, especially content based upon a database like MySQL.
In a practical sense, you must have Apache installed to use PHP on your server. If you do not have Apache currently installed, instructions can be found here.
These instructions assume you have already setup an AWS instance and have an SSH client (like PuTTY) available.
Log in to your instance via the SSH client. Transfer to the root user.
Use YUM to install php
Press “Y” when it asks if you want to install PHP
Verify the installation occurred correctly by starting/restarting the httpd service
Summary of command line inputs
$ sudo su
$ yum install httpd
Do you want to install PHP 5.x (Y/N): Y
$ service httpd restart
The default configuration of PHP is just fine to use for 90% of applications. If you are going to be doing development on the server, it would be appropriate to make a few changes to the php.ini file for the particular development server. These changes should occur in the Apache2 hosting configurations (“/etc/httpd/conf.d/vhosts.conf” in the previous Apache2 instructions). The major issue you would want to change is turning off safe mode.