Some popular web servers are Apache, Apache Tomcat, IIS etc. While Apache is used for PHP pages, Tomcat is used for JSP. IIS is a Microsoft server used for ASP. In this post I will show you how to install Apache and host websites on it.
First of all we need to install Apache. In Ubuntu you can do so by typing
sudo apt-get install apache2
For Fedora fire the following command as super user:-
yum install httpd
Now to verify that you have installed apache correctly open on any browser http://localhost. A page with title "It Works!" will appear confirming the correct installation.
Now that we are done with installation let us host a website. For that you should know that document root is a folder which contains all the pages a website should have. By default index.html is opened if you simply type the address of a website. I am assuming that you want to have /web/adityapatawari.com as document root. Follow the given steps to host your website.
- Copy the default website to use it as a template
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/adityapatawari.com
- Change the DocumentRoot by editing /etc/apache2/sites-available/adityapatawari.com to point to the new location i.e. /web/adityapatawari.com. You will need to have root permission to do this.
- Change the Directory directive, replace <Directory /var/www/>to <Directory /web/adityapatawari.com/ >
- Now disable the previous site and enable this new one. To do so type
sudo a2dissite default && sudo a2ensite adityapatawari.com