How do you set up a virtual host in Apache?
Answers were Sorted based on User's Feedback
Answer / abhay
<VirtualHost www.test.com>
ServerAdmin admin@test.com
DocumentRoot /home/apache/share/htdocs/hostedsites
ServerName www.test.com
ErrorLog /home/apache/logs/error/hostedsites/error_log
TransferLog /home/apache/logs/access/hostedsites/access_log
</VirtualHost>
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / krishna
apache provide two type of virtual hosting 1- ip based and
2- name based.
to configure name based your dns should work properly.
go to the /etc/httpd/conf/httpd.conf file and remove # from
the start of of Namevertualhost *:80
and than at the end of file write the content below
<VirtualHost "IP of your apache server":80>
ServerAdmin root@krishna.com
DocumentRoot /var/www/krishna/krishna.html
DirectoryIndex krishna.html
ServerName www.krishna.com
ErrorLog /home/apache/logs/error/hostedsites/error_log
TransferLog /home/apache/logs/access/hostedsites/access_log
</VirtualHost>
restart your httpd service by running the command
Service httpd restart or /etc/init.d/httpd restart
| Is This Answer Correct ? | 3 Yes | 0 No |
How to ensure apache process run with non-root/nobody user?
Where is apache installed?
Where are the apache logs?
How do I download apache for windows?
Is apache opensource?
How do I stop apache from restarting?
What is apache web server and how it works?
How to to stop apache?
What’s difference between apache web server and apache tomcat?
What is the difference between systemd and upstart?
Is apache still used?
What is the difference between reload and restart?