首页 > 代码库 > lamp-----5 apache虚拟主机实现,发布多个独立站点

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>

技术分享

 

 

测试

技术分享

 

技术分享

 

 

完成。。

 

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