Tuesday, August 07, 2007

Install Apache Webserver on Ubuntu GNU/Linux Box

Installing any software is a breeze on most Debian based distro. The apt-get is such wonderful tool. Here is how to install an apache webserver on Ubuntu. It is understood that your machine has a working internet connection.

$sudo apt-get install apache2 apache2-common apache2-mpm-prefork apache2-utils ssl-cert

(or you could login as su and then do away with the sudo infront)

This would take a few minutes to install and configure. After the installation is done you may need to configure a few parameters to suite your requirements like the apache port number or the webserver root etc.,

By default all your configuration files are located at /etc/apache2
The default document root is at /var/www

To change this edit /etc/apache2/site-available/default

$ gedit /etc/apache2/site-available/default

navigate to the line that says DocumentRoot /var/www edit this line and specify the new webroot.

(You may use vi editor if you are quite familiar with that editor commands)

The main configuration file located at /etc/apache2/apche2.conf

By default Apache2 to Listen on port 80.
If this is not desired, please edit /etc/apache2/ports.conf as desired.

For example if you want to change your apache webserver port to 88 you need to edit /etc/apache2/ports.conf

$ sudo gedit /etc/apache2/ports.conf

Look for the following line

Listen 80 , Replace with the following line

Listen 88 and save the edited file

You may have to restart your apache server
$ sudo /etc/init.d/apache2 restart

and then navigate to http://localhost:/ if you are testing it from the local system or else http://:/ if you are remotely trying to access it.

No comments: