Ubuntu - Apache and PHP install
Ubuntu comes with Apache and PHP and they are easily installed via the default Ubuntu Package Manager 'aptitude'.
The advantage of using aptitude is that you will get any security updates from Ubuntu (if and when distributed) and dependencies are automatically taken care of.
A basic Apache install is very easy:
sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert
Towards the end of the install you will see this warning:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Although I'll be going into some detail about the options and settings available in the main apache configuration file, let's fix that warning straight away.
Open the main apache config:
sudo nano /etc/apache2/apache2.conf
At the bottom of the file add the following:
Change the ServerName to your Cloud Server hostname or a FQDN (remember this demo Cloud Server has a hostname of 'demo').
Once done, save apache2.conf and gracefully restart Apache (this method of restarting won't kill open connections):
sudo apache2ctl graceful
Now the warning has gone. Nice.
If you navigate to your Cloud Server IP address:
You will see the default 'It works!' screen:
Now we have the base Apache install completed, we can move onto installing PHP. If you don't require PHP then please feel free to skip the next section.
In this example, I'm not going to install all the modules available. Just some common ones.
To see what modules are available try a:
sudo aptitude search php5-
Note the '-' at the end of 'php5'. This will show any packages that start with 'php5-' and shows the available modules.
As before, due to using aptitude to install PHP5, any dependencies are taken care of:
sudo aptitude install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd \ php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp \ php5-sqlite php5-xmlrpc php5-xsl
Once done, do a quick Apache reload:
sudo /etc/init.d/apache2 reload
Well, almost done.
We do need to configure Apache for our setup so we can host multiple sites and so on.
The next article will go through the Ubuntu Apache layout as it differs slightly from the 'classic' layout you might expect if you had installed from source.
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER