Running a web server in your Linux box is not a big deal. Most people do get scared when it comes to installing and configuring Linux boxes, as there is a certain level of complexity involved and certain level of skill is required. This brief guide introduces you to the easy steps of installing and configuring a web server in Linux.
First of all, let’s see what we want. We want a Linux box running a standard Linux distribution like Ubuntu or Fedora. Next, we want Apache downloaded and installed. If you have a HTML page done by you, maybe as a part of a hobby or a college project, that is good too.
Step 1: Download and install Apache
Apache is a free and open source web server available for anyone who is willing to host their own web server. Although Apache chargers nothing, it is an enterprise scale web server used by majority of business in the world. So, Apache is not a second class citizen at all; rather, Apache is ‘the’ citizen in web server niche.
Go to www.apache.org and download the latest Apache web server installation to your Linux box. The downloaded Apache installation file will have a name like ‘httpd-x.x.xx.tar.gz’. The ‘x.x.xx’ represents the version of Apache.
Now go to the download directory through the terminal and type the following command.
#tar zxvf httpd-x.x.xx.tar.gz
The above command will create a directory containing the Apache installation files. Now go into the Apache installation directory (using the terminal) and execute the following command.
The above command configures Apache for the installation. The ‘configure’ script looks for dependencies and checks the environment for a successful installation. If something is missing, it will tell you to install the missing package (mostly libraries) before installing Apache.
Once ‘configure’ script is successfully completed, you need to execute the following command in the terminal.
The above command will compile the Apache files in order to suit your Linux box. Usually this step will execute without any error as ‘configure’ script looks for compilation requirements. Once the compilation is successfully completed, execute the following command in order to install the compiled files in the system.
By the end of this process, Apache is successfully installed in your system. But you are not done yet. Now we need to configure and start Apache in order to see hosted web pages.
Step 2: Configure Apache
When it comes to Apache configuration, there is this one file you need to know; httpd.conf. Every configuration you do to Apache should be done by editing this plain text file. Therefore, always remember to create a backup copy of this file before you do any editing. Unless you are trying to make a lot of customizations, you do not need to edit this file. If this is your first time installing and configuring Apache, do not bother to edit httpd.conf file at all. You can do this when you gain more experience with Apache configurations.
Before you access installed Apache, you need to start the Apache server. For that, execute the following command in the terminal.
If you have changed the installation directory during the installation, look in /installation_directory/bin for ‘apachectl’ file.
In case if you want to stop the Apache server, you can execute the following command.
To restart the Apache server,
In order to check the running Apache server, you can type the following URL into your web browser.
Upon entering this URL and pressing enter, you should see a page with Apache logo (refer the image in this article). This means that you have successfully installed your first web server on Linux. Congratulations!