This article describes the CentOS configuration of the virtual host VirtualHost to enable the server to support multiple site multiple domain name method. Share to everyone for your reference, specific as follows:
How to let CentOS (Redhat) Configure the virtual host, let the server support multiple sites, for Apache, only you need to modify the Apache configuration file/etc/httpd/conf/httpd.conf.
There is a example file, you only have to correspond to the configuration.
#<virtualhost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# Documentroot/www/docs /dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/ Dummy-host.example.com-error_log
# Customlog logs/dummy-host.example.com-access_log Common
#</ Virtualhos>
You can refer to my configuration and add at the bottom of the httpd.conf:
Namevirtualhost *:80
<virtualhost *:80>
ServerAdmin admin@example.com
ServerName www.yourweb.com
#ErrorLog/var/log/httpd/yourweb/error_log
#注意, here I set up the production log
in days ErrorLog "|rotatelogs/var/log/httpd/yourweb/error_log%y_%m_%d.log 86400"
#CustomLog/var/log/httpd/yourweb /access_log Common
Customlog "|rotatelogs/var/log/httpd/yourweb/access_log%y_%m_%d.log 86400" common
</VirtualHost>
<virtualhost *:80>
ServerAdmin admin@example.com
documentroot/var/www/ Html/blog
ServerName blog.yourweb.com
errorlog/var/log/httpd/blog/error_log
customlog/var/log/ Httpd/blog/access_log Common
</VirtualHost>
As above I have configured two virtual host: domain name is www.yourweb.com blog.yourweb.com
Note that the restart of Apache does not take effect (service httpd restart)
I hope this article will help you CentOS server management.