繁体   English   中英

如何允许Apache显示除文档根目录以外的其他目录中的内容?

[英]How to allow Apache to display content from other directories than document root?

我已经在Manjaro Linux中安装了Apache版本2.4.29-1 文档根目录是/srv/http ,其中apache可以正确显示文件。 但是我不喜欢编码到系统的root用户目录中的想法,因此我想将代码保留在/home/aditya/Prog/PHP

我通过/etc/httpd/conf/httpd.conf添加到/etc/httpd/conf/httpd.conf来设置apache来访问目录

<Directory /home/aditya/Prog/PHP>
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
    Allow from all
</Directory>

另外,我在/srv/http添加了指向该目录的链接

sudo ln -s /home/aditya/Prog/PHP/ PHP     #in /srv/http

但是当我尝试访问localhost/PHP ,我得到了

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.29 (Unix) PHP/7.2.3 

/home/aditya/Prog/PHP的权限以及其中的测试文件为

drwxrwxrwx   PHP
-rwxrwxrwx   test.php

我还需要做什么?

您还需要更改httpd.conf文件中的DocumentRoot设置。

查找DocumentRoot并将路径设置为/ your / path / to / project。

Apache2站点特定的配置文件保存在/ etc / apache2 / sites-available /中。 如果您只想为特定站点应用配置设置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM