First step towards your own server

As per the Wikipedia a Web server can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that can be accessed through the Internet.

You may want to setupa a webserver to share your contents with the world or for fun or even to make a little bit money. I set up a web server so that i can share things with my friends and so that I don’t have to send attatchments with my mail. I have an unlimited broadband connection so leaving my system online made things easier for me, though I have to shut it down sometitmes.

The most common use of web servers is to host web sites but there are other uses like data storage or for running enterprise applications.
In this post I will show you how to setup a basic web server and in the coming posts i’ll tell you how to go online. The instructions given below are mainly for ubuntu users as that is what I use. But the other Distros too may have the same procedure

Installing Apache:

Downloading the apache packages and compiling them was a bit tricky for me so this is what I did.(you can download apache from here)

Or You can either use the synaptic package manager and search for apache2 or ucan type in the following in the terminal:

  sudo apt-get install apache2

On Ubuntu, the configuration files for Apache are held in the directory ‘/etc/apache2’. To learn what is supported by the web server, visit ‘/mods-enabled’. There several files with a suffix of ‘.load’ are listed. These are the modules themselves, and their configuration files are in the corresponding ‘.conf’ files. To see which modules are available, see the corresponding ‘mods-available’ directory (/etc/apache2/mods-available). Here you will find a list of all the modules that can be enabled. If a module is listed in mods-available but is not found in mods-enabled, it will not be used. To install a new module from those that are available but not enabled, simply copy the appropriate ‘.load’ file to mods-enabled (using ‘sudo’). After copying the module to ‘mods-enabled’, you may still need to configure it.( I copied everything from mods-available to mods-enabled)
Apache on Ubuntu has two main configuration files: apache2.conf and httpd.conf. Both are found in the directory ‘/etc/apache2’. The first configuration file is generated when the server is installed and is rewritten whenever it is upgraded or reinstalled. The second is available for custom, system-wide configurations. To enable the modules you copied, do the following from a terminal:

    sudo gedit /etc/apache2/httpd.conf

and enter

Userdir public_html
Options +Indexes
Options All

ServerName localhost

<Directory “/home/<your user name here>/public_html/”>
Order allow,deny
Allow from all
AllowOverride All

After saving and closing the file, any user can create a directory called ‘public_html’ in their home directory and post web pages to be served from there. If the directory does not exist, the user simply needs to create it (using ‘mkdir public_html’ or right clicking in the file manager while inside their home directory).

Note, however, that indexing still needs to be turned on explicitly by each user. To do so, the following must be saved within the ‘public_html’ directory and in a file named ‘.htaccess’ (note the dot before the ‘h’):

Options +Indexes

After this, restart the server with the following command:

sudo /etc/init.d/apache2 restart

The above modules are just enough to make Apache usable for local users. If you want to use any scripting language like Python, PHP, or Perl, you will need to install each of those module separately. After installation, however, no configuration is needed. Some configuration options (directives) make Apache work better on Ubuntu.

Now fireup your browser and type localhost or And if u see the page like this your installation was fine.


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 )

Facebook photo

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

Connecting to %s