Apache and PHP on Ubuntu – Very Easy Installation

This was very easy – just install php and apache from synaptic and you are good to go. At least for local testing purposes like I am interested in. And if, like myself, you want your test scripts in /home/user/public_html you only need to do the following:

Copy the default website as a starting point.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
Edit the new configuration file
sudo gedit /etc/apache2/sites-available/mysite
Change the DocumentRoot to point to the new location. For example, /home/user/public_html/
Change the Directory directive, replace <Directory /var/www/> to <Directory /home/user/public_html/>

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).
sudo a2dissite default && sudo a2ensite mysite
Finally, we restart Apache2:
sudo /etc/init.d/apache2 restart


NB to install support for mysql (mysqli) use synaptic and search for mysqli.