Simple steps to configure our own web-server on Linux


Servers play a major role in the world wide web. For every single page that is viewed on the browser,a connection is established to a server located elsewhere in the world and the HTML page is downloaded from it. Sometimes, it becomes highly critical to maintain servers and run projects on them. The present post is for beginners of Linux and I would like to give some insights into setting up and maintaining web server in Linux.

Configuring a web server is quite easy.
To configure a server, make sure apache2 is installed in Linux. The server runs as a service and continuously listens to the users who connect to the server and download data. To access server,the process apache2 should be enabled. Use the following commands to know the status of the server, start, stop and restart respectively.

/etc/init.d/apache2 status
/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart

There are two parts or folders in the web server, htdocs and cgi-bin.
htdocs
htdocs is the directory in the webserver where HTML,css and JavaScript files are present. It is located in /var/www/htdocs.To check if server really works, copy a sample HTML page in htdocs,open the browser, and type http://localhost/samplewebpage.html. If the page loads fine, then you have your server running. To view the web page from any other system in LAN, replace localhost with the IP address of the system which is configured as server.

cgi-bin (cgi stands for code graphic interface):
In ubuntu, cgi-bin is located in /usr/lib/cgi-bin, whereas in Suse, it is in /var/www/cgi-bin. The cgi-bin contains the source code of those files which are not visible to the end user, who is browsing the website. For example, if you are using a form to calculate some results,and you would like to share only the functionality of the code and hide all the implementation details and source code, then the code needs to be located in cgi-bin. The files in cgi-bin do not have read and write permissions and have only execute permissions. You can either have a php, or a perl-cgi to execute the code.

Enabling php or perl-cgi in the web-server:
To enable the php or perl-cgi, execution of cgi code for perl or php needs to be enabled. In the file
/etc/apache2/mods-enabled/userdir.conf
replace
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
with
Options MultiViews Indexes SymLinksIfOwnerMatch +ExecCGI
and restart the server by
/etc/init.d/apache2 restart

Enabling database connectivity for perl-cgi or php:
You may also have a database connectivity to your php or perl-cgi code through mysql. In such cases, you need to have mysql installed on your system.
The following are the commands to know the status, start, stop and restart mysql daemon respectively.
/etc/init.d/mysql status
/etc/init.d/mysql start
/etc/init.d/mysql stop
/etc/init.d/mysql restart
Also make sure that the right packages are installed for mysql binding  for perl-cgi or php

To view logs in web-server:
The error logs can be viewed in /var/log/apache2/errorlog. The error log contains details of errors while executing code on the server.
/var/log/apache2/accesslog is the access log file that contains details about the IP addresses of the systems that accessed our server.

Advertisements

7 thoughts on “Simple steps to configure our own web-server on Linux

    1. I prefer ubuntu and gnome. However, I had worked on suse 10.4 and 11.1 earlier, but found that suse works quite well with gnome. There were a few issues with suse on KDE. Suse used to crash quite often with KDE.

      Like

  1. I did put ubuntu on a laptop that I almost never use, jsut to try a different distro. But it’s so much easier to stick with the one I know. Right now I’m having trouble with LIbre Office, and thinking about trying to go back to OpenOffice. I’ll have to install it – it doesn’t come with Suse any more.

    Like

  2. I do not even know how I finished up right here, but I thought this post was once great. I do not know who you are however definitely you are going to a well-known blogger in the event you are not already. Cheers!

    Like

  3. Checking out the error logs is important especially in reconfiguring your server in Linux. After doing so, and figuring out which steps work and which don’t , then you are finally able to get set up completely.

    Like

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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