这就是我正在尝试做的事情。
我尝试向 apache 添加另一个文件夹,但在尝试访问时出现以下错误testing/index.html
。
我的想法是,我想为每个顾客提供一个像这样的文件夹/home/neagoe/Work/InterWebs/Projects/[PROJECT NAME]/CustomerProjects/website/dist
。
Forbidden
You don't have permission to access /index.html on this server.
Apache/2.2.22 (Ubuntu) Server at testing Port 80
以下是我遵循的步骤:
步骤1:
sudo chmod a+x /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist
第2步:
sudo chown -R www-data:www-data /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist
sudo chmod -R 775 /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist
步骤3:
sudo adduser $USER www-data
步骤4:
sudo a2enmod userdir
步骤5:
sudo cp /etc/apache/sites-available/default /etc/apache/sites-available/testing
我编辑了该文件/etc/apache/sites-available/testing
,因此它看起来像这样:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName testing
DocumentRoot /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist/ >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
步骤6:
我编辑了主机(“/etc/hosts”),因此它看起来像这样:
127.0.0.1 localhost
127.0.0.1 testing
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
步骤7:
sudo a2ensite testing
sudo service apache2 restart
我在网上搜索了大约 2 个小时,但还是不知道哪里出了问题。我找到的所有页面都遵循了上述相同的步骤。
我知道互联网上有类似的问题,但答案是更改目录的权限,我在第2步。
如果这确实是重复的,我很抱歉,但我找不到正确的答案。
谢谢你!
PS. 我也在 AskUbuntu 上问过这个问题,但是没有得到任何答案,所以我在这里试试运气。
编辑:
错误日志和访问日志中没有太多内容。
在access.log
:
::1 - - [10/Aug/2013:11:23:28 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:29 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:31 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:32 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:33 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:34 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:35 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
127.0.0.1 - - [10/Aug/2013:11:23:23 +0300] "POST /wordpress-testing/wp-cron.php?doing_wp_cron=1376123003.7026669979095458984375 HTTP/1.0" 200 705 "-" "WordPress/3.6; http://localhost/wordpress-testing"
::1 - - [10/Aug/2013:11:23:36 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:37 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
::1 - - [10/Aug/2013:11:23:38 +0300] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.2.22 (Ubuntu) (internal dummy connection)"
127.0.0.1 - - [10/Aug/2013:11:31:32 +0300] "GET /index.html HTTP/1.1" 200 485 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0"
最后一行重复约 200 行。
在error.log
:
1. 这句话时不时地会重复出现。
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525 /msql.so' - /usr/lib/php5/20100525/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Sat Aug 10 13:06:42 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.9-4ubuntu2.2 configured -- resuming normal operations
[Sat Aug 10 13:07:36 2013] [notice] caught SIGTERM, shutting down
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/msql.so' - /usr/lib/php5/20100525/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[Sat Aug 10 13:07:37 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.9-4ubuntu2.2 configured -- resuming normal operations
2. 这是主要的错误。(数百行)
[Sat Aug 10 13:07:40 2013] [error] [client 127.0.0.1] (13)Permission denied: access to /index.html denied
答案1
上面有目录/home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist/
覆盖了权限。尝试修改根目录以
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
虽然这不是一个理想的解决方案,但它可以帮助你找出被阻止的地方。然后,我会在根目录中尝试混合Allow
和Deny
语句,直到获得可接受的安全性和功能性组合。
答案2
您需要验证通向最终目录的所有目录是否都可以被 Apache 访问。
/home/neagoe/Work/InterWebs/Projects/testing/CustomerProjects/website/dist
最常见的情况是,主目录 (/home/neagoe) 的权限为 750 或 700,以阻止其他用户访问。这对 Apache 来说是个问题。
如果是这种情况,您可以chmod 755
这样做(首先考虑在您的环境中这样做是否存在任何安全风险)或chmod 750
(在这种情况下记得将 Apache 添加到拥有目录的组中)。