How to access the web server through a hostname?
Step1: Check for the package installed or not
#rpm -qa | grep httpd
Step2 : Install the package
#yum install httpd
Step3 : For hostbased web access we require DNS server entries of our host.
Example host in this post is : server1.example.com(Actual server name) and
hostbase.example.com(our virtual host name)
So we have to give A record for the server1.example.com and CNAME record for hostbase.example.com which points to server1.example.com Step3 : Create the root web directory and a test index.html for this testing. I want to create my web directory in /hostnamebase #mkdir /hostnamebase
Now create index.html and try to write something in to that file then save the file. #vi /hostnamebase/index.html save and exit the file. Step4 : Now edit the httpd.config file #vi /etc/httpd/conf/httpd.conf Step4(a) : Please specify the NameVirtualHost NameVirtualHost 192.168.0.1 What is the significance of this entry? Ans : This directive is a set to IP address/actuall system name if you want to configure your server to host. Name based virtual hosting. So here i am using ip address of my system. You can try to put actual hostname if you want to test it. Step4(b) : Now configure virtual host entry as shown below. Go to last line and write the below content <VirtualHost 192.168.0.1>
ServerName hostbase.example.com
DocumentRoot /hostnamebase/
DirectoryIndex index.html
</VirtualHost> Save the file and exit. Let me explain ServerName entry ServerName hostbase.example.com This is used to specify what is the virtual host name of your new Virtualhost. So user can type this FQDN to access this site. Now save the file and exit.
Step5 : Check for the syntax errors in the httpd.conf file before restarting the apache service. #httpd -t Or #httpd -k graceful Step6 : Now start the service and then add it to booting scripts so that it will start automatically at every boot of the system
#service httpd restart
#chkconfig httpd on
Step7 : Now check the site using http://hostbase.example.com in your browser.
Latest posts by Surendra Anne (see all)
- Docker: How to copy files to/from docker container - June 30, 2020
- Anisble: ERROR! unexpected parameter type in action:
Fix - June 29, 2020 - FREE: JOIN OUR DEVOPS TELEGRAM GROUPS - August 2, 2019
- Review: Whizlabs Practice Tests for AWS Certified Solutions Architect Professional (CSAP) - August 27, 2018
- How to use ohai/chef-shell to get node attributes - July 19, 2018