我尝试向 apache 添加另一个文件夹,但在尝试访问时出现以下错误testing/index.html
。
我的想法是,我想为每个顾客提供一个像这样的文件夹/home/neagoe/Work/InterWebs/Projects/[PROJECT NAME]/CustomerProjects/website/dist
。
禁止
您无权访问此服务器上的 /index.html。Apache/2.2.22 (Ubuntu) 服务器正在测试端口 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 个小时,但还是不知道哪里出了问题。我找到的所有页面都遵循了上述相同的步骤。
我知道 AskUbuntu 上有类似的问题,但答案是将权限更改为我在第2步。
如果这确实是重复的,我很抱歉,但我找不到正确的答案。
谢谢你!
答案1
我遇到了同样的问题,我编辑文件/etc/apache2/apache2.conf
并添加
<Directory /var/www/ >
Order allow,deny
Allow from all
Require all granted
</Directory>
并重置 apache2
sudo service apache2 restart
为我工作。