linux系统apache配置虚拟目录

0.在根目录设置两个文件夹app2并新建index.html

mkdir /app2

echo "hello app2" > index.html

1.httpd.conf配置如下内容:

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

2.把selinux防火墙设置为允许访问(permissive)

setenforce 0


3.重启httpd

service httpd restart


4.curl localhost/app22/  或用浏览器输入"相应的ip"/app2访问


5.注意点

如果没用setenforce 0

没有配置

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

</Directory>

则访问时会报错:You don't have permission to access

猜你喜欢

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