Setup Ubuntu as a Web Server

So these are the general steps for setting up a web server (Apache, MySQL and PHP) on a Ubuntu 10.4 server. If you are not sure on how to use unix command line see:

Upgrade Ubuntu

apt-get update
apt-get upgrade --show-upgraded

Install Apache MySQL and PHP

apt-get install apache2 mysql-server php5 php-pear php5-mysql

Then Secure MySQL


Setup vhosts

Create a file in the /etc/apache2/sites-available/ directory for each virtual host that you want to set up. Name each file with the domain for which you want to provide virtual hosting. See the following example configurations for the hypothetical “” domain.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /srv/www/
     ErrorLog /srv/www/
     CustomLog /srv/www/ combined

Then create the folders

mkdir -p /srv/www/
mkdir /srv/www/

Enable the site and reload Apache

/etc/init.d/apache2 reload

Install mod_rewrite

sudo a2enmod rewrite
sudo /etc/init.d/apache2 reload

You also need to find this file:


and change “AllowOverride None” to “AllowOverride All” it appears a couple of times.

Install PHPMyAdmin

sudo apt-get install phpmyadmin

“In /etc/apache2/apache2.conf” Add “Include /etc/phpmyadmin/apache.conf” The restart apache

/etc/init.d/apache2 reload

Install XBedug - Optional for DEV only

sudo apt-get install php5-dev php-pear
sudo pecl install xdebug

Make a note of the location of the then create a xdebug.ini with the below info and put it into “/etc/php5/conf.d”

; xdebug debugger
# IN php.ini file make sure html_errors = true
/etc/init.d/apache2 restart

PHP Important Folder and Files

# /etc/php5
# /etc/php5/apache2/php.ini

Apache Important Folder and Files

# /etc/apache2/
# /etc/apache2/apache2.conf
# /etc/apache2/sites-available/default

Web Folders

# /srv/www/

or the default location

# /var/www

Other Steps

Change php.ini errors to show all