简体   繁体   中英

Create a virtual host Cent OS

How to create a virtual host in cent os?

I have change some in /etc/httpd/conf/httpd.conf file

<VirtualHost local.mydomain.com>
ServerAdmin webmaster@mydomain.com
DocumentRoot /var/www/html/test/
ServerName local.mydomain.com
ServerAlias local.mydomain.com
</VirtualHost>

and in /etc/hosts file

127.0.0.1       dexs01 localhost.localdomain6 localhost #existing lines
::1             localhost6.localdomain6 localhost #existing lines
127.0.0.1       local.mydomain.com       local.mydomain.com #my addition

and then I restarted my Apache server so what wrong in this?

you have to define in the VirtualHost directive the IP and the port:

<VirtualHost *:80>
  ...
  ServerName local.mydomain.com
  ...
</VirtualHost>

the rest looks good.
note: in your case you do not need the ServerAlias directive because it matches your ServerName.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM