This post is basically a summary of my experiences of setting up a web server under Ubuntu 10.04. I will start with where to get Apache, then move on to installation and basic configuration. This article is written from the point of view of my system, which is a Ubuntu 10.04 (Lucid lynx). In next posting, I will post my experience on protecting web directory with password using .htaccess
1. Apache web-server
Apache is the most commonly used Web Server on Linux systems. The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The current release of Apache Server version is 2.2.17
Web Servers are used to serve Web Pages requested by client computers. Clients typically request and view Web Pages using Web Browser applications such as Firefox, Opera, or Crome.
The Apache2 web server is available in Ubuntu Linux distributions. Using either the Synaptic Package Manager, Ubuntu Software Center, search and install the “apache2″ module. Better way is, you can open a terminal and type the following command:
sudo apt-get install apache2
Once the installation finished with successful flag, open browser and enter “http://localhost/”. If you see the page “It Works!”, then your installation of apache is successful.
The following commands allow you to start, restart, stop and check status of Apache:
sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 restart
sudo /etc/init.d/apache2 status
Changing the default localhost directory
By default, apache web server root directory points to ‘/var/www/’ directory. Whatever files you place in this ‘/var/www/’ directory will be accessible/visible from the “http://localhost”.
In any case, as per requirement admin may want the “localhost” should point to some another directory, (say) ‘/home/nitin/public_html’.
mkdir -p /home/nitin/public_html
cd /home/nitin/public_html vim index.html
Create a simple html file, name it
index.html and place it in the ‘public_html’ directory. Now, Tell web server to update pointer to newly created directory.
sudo vim /etc/apache2/sites-enabled/000-default
DocumentRoot /var/www to
DocumentRoot /home/nitin/public_html. also, Change
<Directory /var/www/> to
After editing save file and exit. Then, restart apache server:
sudo /etc/init.d/apache2 restart
Now, in your browser, reload the “http://localhost”.
You should see the html file that you have placed in the ‘public_html’ directory.
Configuring to different ports
Some of user may want that server should listen on specific port, then change the port number in ‘/etc/apache2/port.conf’ to any port you want. You will likely to also have to change the VirtualHost statement in ‘/etc/apache2/sites-enabled/000-default’
Prevent apache from autostart
By default, apache server autostarts and keep running as daemon when Ubuntu machine boots up, to prevent Apache from autostart when booting up:
sudo update-rc.d -f apache2 remove
To restore Apache back to the autostart list:
sudo update-rc.d apache2 defaults
Congratulations!! You now have Apache installed on your Ubuntu Linux
Other than that, I would love to hear any comments and/or suggestions you may have about what I wrote.