Apache 使用软连接设置访问路径遇到的问题总结


#目录的链接属性

[root@IT-test webapps]# ll /alidata/xx/webapps/xx
lrwxrwxrwx 1 root root 15 9月   1 10:53 /alidata/xx/webapps/xx -> /root/test/mail
[root@IT-test webapps]# ll /root/test/mail/
总用量 12
-rw-r--r-- 1 root root   7 8月  10 17:08 1.txt
-rwxr-xr-x 1 root root 348 8月  11 14:12 curl_interhb.sh
-rw-r--r-- 1 root root  11 9月   1 10:00 index.html


#Apache中vhosts配置的虚拟主机xx.dyb.com

[root@IT-test webapps]# tail -100 /usr/local/apache2/conf/extra/httpd-vhosts.conf 

<VirtualHost *:80>
    ServerAdmin admin@dyb.com
    DocumentRoot /alidata/xx/webapps/xx
    <Directory "/alidata/xx/webapps/xx">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ServerName xx.dyb.com
    DirectoryIndex index.html index.htm index.jsp
    ErrorLog logs/uh.dyb.com_error_log
    CustomLog logs/uh.dyb.com_access_log common
</VirtualHost>

1. 访问xx.dyb.com时出现 503 错误

这个原因是因为Options -Indexes FollowSymLinks,Indexs属性用来控制允许显示目录下的文件列表,没有特殊需求最好不开启。

需要将这一条参数改为Options Indexes FollowSymLinks



2. 访问xx.dyb.com时出现403错误

报错信息为:Symbolic link not allowed or link target not accessible

这个原因是/alidata/xx/webapps/xx  链接到的/root/test/mail/目录需要有执行权限

执行chmod -R +x /root