Setting up Apache on Ubuntu

To enable sites to be served locally on Ubuntu I needed to install a web server and the obvious choice is Apache. To install I used the apt-get command in the terminal window:

sudo apt-get apache2

This installs apache to the /etc/apache2 directory. To test the install, browse the http://localhost address in the browser. You should get a confirmation screen. Within the apache2 directory is the apache2.conf file, which contains all the config data for the web server to run.

I wanted to change the directory which Apache runs from, which is controlled the DocumentRoot setting, which has /var/www as the default directory. I changed this setting to point to /home/alex/www and put index.html into this directory to test that apache could find the file by browsing to localhost again. I just needed to restart apache for the DocumentRoot setting to take effect:

sudo /etc/init.d/apache reload

The one other thing to bear in mind is permissions. For apache to serve files in the www directory, the files need read permission setting for others.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s