The cross platform supported apache web Server is a free and open source server. From the linux repository we can install it easily. Generally, it works with PHP language and MySql Database. Other’s platform are also supported.
In this lesson, we will install apache web server on Ubuntu 16.04 machine. The command also work for other releases. But there is some exception. Some of the command may not applicable for other releases.
All the command must be run with root privileges. To install apache web server from the repository, please run the following command:-
apt-get –y install apache2
After the installation complete, we have to configure the apache web server. To configure web server, we have to modify some couple of files. In this tutorial, we will use “vi” text editor for file modification.
First of all we will configure the server token setting for security reason. This setting is responsible for what you want to return as the server HTTP response header. The default setting is “full”, where conveys the most information. That’s why, most of the server information are publicly available. Now, we are going to change that to “Prod”, where conveys the least information. The file name we have to modify is security.conf which is available at “/etc/apache2/conf-enabled/” path. To opening this file the complete command will be:-
vi /etc/apache2/conf-enabled/security.conf
Now find out the “ServerTokens” setting and change it’s value to “prod” and also find out the “ServerSignatue” setting and change it’s value to “off”. As like below:-
ServerTokens prod
ServerSignature off
Now we are going to change the “directory index” value. By using this value, we are telling our server that, what will be the default page if a user browse our web server. We can set the default page to index.html or index.php whatever we like. For that, we have to configure “dir.conf” file, which located at “/etc/apache2/mods-available/”. To opening this file, the complete command will be:-
vi /etc/apache2/mods-available/dir.conf
Now change the “DirectoryIndex” value to “index.php” or “index.html”, whatever you want.
DirectoryIndex index.php
Or
DirectoryIndex index.html
You can keep multiple file type if you want. But for the security reason, it is recommended to keep only one file type. This is look like as follows:-
DirectoryIndex index.html index.php index.cgi
Now we are going to modify our server name. we can change it by editing the “apache2.conf” file which located at “/etc/apache2/”. The command will be the as follows:-
vi /etc/apache2/apache2.conf
Now find out the “ServerName” setting and change it’s value as your requirement.
ServerName server.example.com
Now we are going to set the server admin email address, so that if anything goes wrong, apache can send an email to it’s admin. To set that open the “000-default.conf” file located at “/etc/apache2/sites-enabled/”. Now open this file with “vi” text editor and change it’s “ServerAdmin” address.
vi /etc/apache2/sites-enabled/000-default.conf
Now go to the “ServerAdmin” line and change it’s value as yours. That will be as follows:-
ServerAdmin webmaster@example.com
We are done. Now we have to restart our apache service. To restart that, please use the following command:-
systemctl restart apache2
Now open your browser and go to your website by using your hostname or ip address. Such as:-
http:// {type your hostname or your ip address}/
Now the apache webserver default page should be appeared.
No comments:
Post a Comment