提示:任何时候都要备份;
1、一个web服务可以使用不同的主机名、端口、ip来部署多个web服务;
2、用主机名配置虚拟主机;
打开apache的配置文件
vim httpd-vhosts.conf
(提示:主配置文件中默认是没有打开的)
<VirtualHost *:80>
28 ServerAdmin lingchaoxx@live.com
#填写自己的邮箱
29 DocumentRoot "/var/html/www"
#网站对应的目录,稍后自行创建
30 ServerName www.etiantian.org
#域名
31 ServerAlias etiantian.org
#别名
32 ErrorLog "logs/www-error_log"
#错误日志的路径
33 CustomLog "logs/www-access_log" common
#访问日志的路径
34</VirtualHost>
2、创建与 DocumentRoot "/var/html/www" 相对应的站点目录,创建index.html文件;
创建与 ErrorLog "logs/www-error_log" 相对应日志目录;
3、到主配置文件打开包含vhosts.conf
去掉# 打开 Include conf/extra/httpd-vhosts.conf 关键 (或打开mpm.conf)
vi httpd.conf
377 # Server-pool management (MPM specific)
378 Include conf/extra/httpd-mpm.conf
379
395 # Virtual hosts
396 Include conf/extra/httpd-vhosts.conf
在主配置文件末尾添加网站的路径
添加一个就可以,不需要每个虚拟主机都添加;
<Directory "/var/html">
Options -Indexes FollowSymLinks
Allow from all
</Directory>
保存;
4、检查语法后,重启apache;
转载于:https://blog.51cto.com/linuxboys/1575020