Install and configure Apache webserver in linux

Install and configure Apache webserver in linux

This blog is going to help you how to install and configure apache in linux. In this blog will configure basic setup of apache which will helpfull for linux beginners. We will configure virtual host and bring up a webpage using index.html.

 

Install and configure Apache webserver in linux

I am using redhat linux operating system. The apache configuration explained in this blog will be same for Centos / Fedora and Redhat linux.

Install and configure Apache webserver in linux

Install httpd RPM files using below RPM command

rpm -ivh httpd-2.2.3-11.el5.i386.rpm
rpm -ivh httpd-devel-2.2.3-11.el5.i386.rpm
rpm -ivh httpd-manual-2.2.3-11.el5.i386.rpm

If you have configured Yum repository server already use below command to install

yum install httpd-*

Install and configure Apache webserver in linux
Apache rpm files are installed successfully. Apache uses httpd service. Let’s learn how to stop, start, restart, reload and check status of the apache httpd service.

To check the status of apache httpd service
/etc/init.d/httpd status

To start the apache httpd service
/etc/init.d/httpd start

To restart the apache httpd service
/etc/init.d/httpd restart

To reload the apache httpd service
/etc/init.d/httpd reload

Another Method

To check the status of apache httpd service
service httpd status

To start the apache httpd service
service httpd start

To restart the apache httpd service
service httpd restart

To reload the apache httpd service
service httpd reload

Previously we have seen how to start, stop and restart apache service in ubuntu or Debian Operating System

Install and configure Apache webserver in linux

By default the Apache configuration files are located in “/etc/httpd”. The main configuration file of apache is “/etc/httpd/conf/httpd.conf”. The default location of log file is /var/log/httpd/ . To know more about configuring apache logs check blog Configuring Apache log files.

Let’s configure virtual host using apache webserver. To configure Virtual host open the apache configuration file “/etc/httpd/conf/httpd.conf” using vi editor. Navigate to the last line of the file. Then copy the last 7 lines and paste at the end of the file. Then unhash the first 3 line and last line. First add IP address in virtualhost line then add email ID in serveradmin line then finally add the pointed document root path in the document root line.

After editing the httpd configuration file check the syntax status before restarting the service. If something wrong in the syntax httpd service will not come up and you will end up in problem. If “httpd -t” command gives output as “Syntax OK” output we can restart the service with out any worries.

Install and configure Apache webserver in linux

In our scenario document root is pointed to “/var/www/html”. The file name index.html or index.php will be displayed in the webpage. As of now i am not using php hence i am creating file index.html for displaying message in my website.

To see the webpage open your browser and enter your server IP address and give enter.

Install and configure Apache webserver in linux




Leave a Reply

Your email address will not be published. Required fields are marked *