配置apache基于IP的虚拟主机

0.我用桥接的方式为虚拟机配置了两张网卡如下:



1.在系统根目录下创建文件夹app1  app2  创建index.html  如:/app1/index.html   /app2/index.html



2.httpd.conf配置如下:

Alias /app11 /app1
<Directory "/app1">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        Require all granted
</Directory>

Alias /app22 /app2
<Directory "/app2">
#       AuthType Basic
#       Authname "This is a private dir"
#       AuthUserFile /etc/httpd/password
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
        Require all granted  
#       Require valid-user

</Directory>

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /app1
 ServerName 192.168.1.100
 ErrorLog logs/100error
 CustomLog logs/100access common
</VirtualHost>

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /app2
 ServerName 192.168.1.106
 ErrorLog logs/106error
 CustomLog logs/106access common

</VirtualHost>


3.httpd.conf配置端口监听IP



4.service httpd restart

5.测试




猜你喜欢

转载自blog.csdn.net/qq692042122/article/details/80646550