lamp-----5 apache虚拟主机实现,发布多个独立站点

Posted 奥特最帅

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了lamp-----5 apache虚拟主机实现,发布多个独立站点相关的知识,希望对你有一定的参考价值。

1.。。基于ip

vi /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.1.142:80>
ServerName 192.168.1.142:80
DocumentRoot /web/upload

<Directory "/web/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/142error.log
CustomLog /var/log/httpd/142access.log combined
</VirtualHost>

 

 

<VirtualHost 192.168.1.143:80>
ServerName 192.168.1.143:80
DocumentRoot /var/www/html/upload

<Directory "/var/www/html/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/143error.log
CustomLog /var/log/httpd/143access.log combined
</VirtualHost>

 

 

systemctl restart httpd.service

 

测试

 

 

 

2.。。基于端口

vi /etc/httpd/conf/httpd.conf

 

<VirtualHost 192.168.1.142:80>
ServerName 192.168.1.142:80
DocumentRoot /web/upload

<Directory "/web/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/142error.log
CustomLog /var/log/httpd/142access.log combined
</VirtualHost>

<VirtualHost 192.168.1.142:8091>
ServerName 192.168.1.142:8091
DocumentRoot /var/www/html/upload

<Directory "/var/www/html/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/143error.log
CustomLog /var/log/httpd/143access.log combined
</VirtualHost>

 

 

测试

 

 

 

完成。。

 

3.。。。基于域名

vi /etc/httpd/conf/httpd.conf

NameVirtualHost *:80

<VirtualHost 192.168.1.142:80>
ServerName www.han.com
DocumentRoot /web/upload

<Directory "/web/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/142error.log
CustomLog /var/log/httpd/142access.log combined
</VirtualHost>

<VirtualHost 192.168.1.142:80>
ServerName www.lei.com
DocumentRoot /var/www/html/upload

<Directory "/var/www/html/upload">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /var/log/httpd/143error.log
CustomLog /var/log/httpd/143access.log combined
</VirtualHost>

 

 vi /etc/hosts

 

 

 

以上是关于lamp-----5 apache虚拟主机实现,发布多个独立站点的主要内容,如果未能解决你的问题,请参考以下文章

LAMP--5.测试 php 解析

Linux系统之Apache虚拟主机的三种实现方式

配置apache虚拟主机,实现在一台服务器上运行多个网站

apache2虚拟主机实现一个服务器绑定多个域名

Apache2.4多虚拟主机VirtualHost三种实现

apache实现多域名虚拟主机的SSL认证