Apache2.4虚拟主机设置

//配置虚拟机主机

cd/etc/httpd/
mkdir vhost-conf.d
添加 配置进 httpd.conf
echo “Include vhost-conf.d/*.conf” >> conf/httpd.conf

vi/etc/httpd/vhost-conf.d/vhost-name.conf

//添加如下内容


ServerName www.xxx.com
DocumentRoot /var/www/html/www/


Requireall granted


ServerName aaa.xxx.com
DocumentRoot /var/www/html/aaa/


Require ip 192.168.188.0/24 //可以设置访问限制

##############################################3
另外一个例子

#端口自定
ServerAdmin [email protected]
DocumentRoot “绝对路径”
ServerName localadm
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common


ServerAdmin 邮箱
DocumentRoot “绝对路径”
ServerName localadm
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common