CentOS7配置Apache多站点VirtualHost
2023-06-13 09:11:02 时间
这里介绍基于主机名的配置方法
环境目录:
- 修改hosts文件
IP地址 www.wscon.cn www.wsczx.com
- 修改httpd.conf文件
修改httpd.conf文件 在文件最后添加 Include vhost-conf.d/*.conf
或者使用命令
echo "Include vhost-conf.d/*.conf" >> conf/httpd.conf
- 修改httpd-vhosts.conf文件
//配置虚拟机主机
#cd /etc/httpd/
# mkdir vhost-conf.d
# vi /etc/httpd/vhost-conf.d/vhost-name.conf
//添加如下内容
<VirtualHost *:80>
ServerName wscon.cn
ServerAlias wscon.cn www.wscon.cn
DocumentRoot /var/www/html/site1
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "/var/www/html/site1/">
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
<VirtualHost *:80>
ServerName wsczx.com
ServerAlias wsczx.com www.wsczx.com
DocumentRoot /var/www/html/site2/
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "/var/www/html/site2/m~@~\>
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
<VirtualHost *:80>
ServerName test.wsczx.com
# ServerAlias wsczx.com www.wsczx.com
DocumentRoot /var/www/html/site3/
DirectoryIndex index.html index.php
</VirtualHost>
<Directory "/var/www/html/site3/m~@~\>
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Allow from All
</Directory>
虚拟主机配置到此结束;在对应的目录下新建html页面测试即可;
相关文章
- CentOS7打开、关闭端口[通俗易懂]
- centos7 top命令_linux chmod命令
- Centos7安装chrome浏览器
- centos7 apache 安装配置步骤[通俗易懂]
- Centos7搭建PPTP V**
- CentOS7部署svn+apache
- CentOS7安装Redis最新版
- Linux一键挂载远程FTP到本地目录,CentOS7.X
- centos7安装ImageMagick
- centos7 安装 mysql5.7 日志
- Centos7安装和卸载Mongodb数据库的方法
- CentOS7安装Python3.7详解编程语言
- 结合开发,推动进步: Apache与MySQL的协作(apache和mysql)
- Linux 下 Apache 服务器安装指南(linux安装apache)
- 的结合Apache和MySQL的完美结合(apache与mysql)
- apache深度探索Linux下的Apache服务器(linuxgt)
- 如何在Apache中配置MySQL数据库连接(mysql、apache)
- Linux+php+apache+oracle环境搭建之CentOS下安装Apache