Learn to configure HTTP SERVER or Apache Web Server in RHEL5 or RHEL6. This tutorial is all about Web server configuration in Linux.Here we are using Apache service as web service.Configuration of Apache web server in RHEL5 and RHEL6 are very similar.So if you know how to configure Apache web server on Redhat Enterprise Linux5 then you can easily do the same for Redhat Enterprise Linux 6.The configuration of Apache Web server on RHEL 7 machine is very different from RHEL5 and RHEL6.I will write a separate and dedicated article on Apache Web server configuration on RHEL7.I have also included Apache Interview Questions with Answers.So if you are preparing for a linux Administrator Interview then this tutorial is for you and will help you to crack your Linux Admin Interview.If you face any more questions apart from this you can ask me though comment section.I will try to include your question with answer and update mt article.
Step 1:Install Packages required for HTTP service
#yum install http* -y
STEP 2: Go to /var/www/html folder and create your web page index.html
[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim index.html
This is a testing site
providing security to this site
save and quit
STEP 3:Apache Sever Configuration File /etc/httpd/conf/httpd.conf
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
<VirtualHost 192.168.0.102:80> DocumentRoot /var/www/html DirectoryIndex index.html </VirtualHost>
Explanation of Above Command:192.168.0.102 is My Apache Machine IP Address. /var/www/html is the folder where i will keep my website data. index.html is the default Page of my site.It Means if someone open my site using ip address or doamin name the first page displayed will be index.html.
Qusestion: - What is DocumentRoot ?
it is a location of files which are accessible by clients. Remember By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
STEP 4: Check for Syntax error after making changes in Configuration File.
[root@localhost ~]# httpd -t
STEP 5: Start Apache Services
[root@localhost ~]# service httpd restart
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# service httpd status
httpd (pid 17768) is running…
STEP 6: Test Web server working or not.
For testing web server open your browser and type ip address of apache server.
If you want to Open page in terminal just type below command:
[root@localhost ~]# elinks 192.168.0.102
STEP 7:Configure Firewall to allow HTTP service.
- # iptables -A INPUT -p tcp –dport 80 -j ACCEPT
- #service iptables save
Apache Server Interview Questions and Answers
Apache bench marking
Question:Now a question arises that Which tool you have used for Apache benchmarking?
Answer is ab (Apache bench)
[root@localhost html]# ab -n 1000 -c 10 http://192.168.0.103/index.html
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.0.103 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.3
Server Hostname: 192.168.0.103
Server Port: 80
Document Path: /index.html
Document Length: 480 bytes
Concurrency Level: 10
Time taken for tests: 0.139123 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 714000 bytes
HTML transferred: 480000 bytes
Requests per second: 7187.88 [#/sec] (mean)
Time per request: 1.391 [ms] (mean)
Time per request: 0.139 [ms] (mean, across all concurrent requests)
Transfer rate: 5009.96 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 2
Processing: 0 0 1.1 1 4
Waiting: 0 0 0.7 0 3
Total: 0 0 1.1 1 4
Percentage of the requests served within a certain time (ms)
100% 4 (longest request)
Limit Upload on Your Web server:
Question: – How you will put a limit on uploads on your web server?
Answer:This can be done by LimitRequestBody directive.
Here I have put limit of 100000 Bytes
Stop People to visit your site though Proxy server.
Question : – If I want to stop people using my site by Proxy server. Is it possible?
Answer:Yes it is possible to stop people from visiting your site through proxy server.Watch the configuration i have mentioned below in apache main configuration file.
Deny from all
Record MAC Address of Clients
Question: Is it Possible to record the MAC (hardware) address of clients that access your server.
Question: – On which port Apache server works ?
http – port 80
https – port 443
Apache Log Files
Question: – What is the location of log files for Apache server ?