vim /etc/httpd/conf.d/vhost.conf
#DocumentRoot和Directory更换自己的项目绝对路径
#ServerName和ServerAlias更换自己的项目地址
<VirtualHost *:80>
DocumentRoot "/var/www/html/test1"
ServerName test1.com
ServerAlias www.test1.com
<Directory "/var/www/html/test1">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/test2"
ServerName test2.com
ServerAlias www.test2.com
<Directory "/var/www/html/test2">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
第七步:确认apache配置是否正确并重启apache服务
#确认apache配置是否正确
httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified
domain name, using localhost.localdomain. Set the 'ServerName' directive
globally to suppress this message
Syntax OK
#重启apache服务
service httpd restart