Set up Web Server using httpd on Linux

We have used Apache HTTP Server on Fedora Linux version 20.  In order to Set up Web server, make sure you have the httpd is installed.

Check for installed httpd Web Server

rpm –q httpd

If server is not installed it can be installed using yum. In terminal change to root user and use the following command

yum install httpd

Set up Web Server – Configuring httpd

The main configuration file for Apache httpd Web server is

/etc/httpd/conf/httpd.conf

The configurations in this file are sufficient enough to support a basic Set up Web Server. The root of Web server is

/var/www/html

You can change root of your web server by changing

DocumentRoot /var/www/html

to your desired location

Check your configuration file after changes for error

service httpd configtest

The log file for httpd Web Server is

/var/log/httpd

Starting the httpd Service

Next step to Set up Web Server is to enable your httpd server, change to root in terminal mode and type command

systemctl enable httpd.service

After enabling your Web Server will start at time of Booting of Server

To run the httpd service, type the following in terminal mode as root user

systemctl start httpd.service

To Stop your web server, type the following in terminal mode as root user

systemctl stop httpd.service

Virtual Hosting

Apache Web Server also support virtual hosting that can be an ip address base or name based host. In order to Set Up Web Server Virtual host use  <VirtualHost> section of configuration file.

<VirtualHost *:80>

ServerAdmin  webadmin@localhost

DocumentRoot /var/www/html

ServerName  www.test.com

</VirtualHost>

The configuration options  for Set up of Web Server, are many I have only listed a few. Leave a comment for any other configuration option.