Redhat系列,如CentOS就更为简单啦
Apache2 配置文件位于 /etc/httpd/conf/httpd.conf
打开拉到最后,去掉 NameVirtualHost *:80 前的 #
然后按照给的例子配置虚拟主机
# VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for requests without a known # server name. # <VirtualHost *:80> ServerAdmin example2@live.com DocumentRoot /var/www/html/example2.com/docs/ ServerName example2.com ServerAlias www.example2.com ErrorLog /var/www/html/example2.com/logs/errorlog.txt CustomLog /var/www/html/example2.com/logs/access_log combined </VirtualHost> <VirtualHost *:80> ServerAdmin example1@live.com DocumentRoot /var/www/html/example1.com/docs/ ServerName example1.com ServerAlias www.example1.com ErrorLog /var/www/html/example1.com/logs/errorlog.txt CustomLog /var/www/html/example1.com/logs/access_log combined </VirtualHost>
再重启下Apache 就可以了。