You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 23.10下Apache2访问用户目录出现Permission Denied问题求助

Ubuntu 23.10下Apache2访问用户目录出现Permission Denied问题求助

我在Ubuntu 23.10上用Apache 2.4.57搭建站点,想把用户目录/home/amiroof/Projects/amiroo54.github.io/作为网站根目录,但访问时一直报权限拒绝的错误,试了网上各种权限设置方法都没用,实在没辙了,来求助大家!


我的配置文件内容

apache2.conf

DefaultRuntimeDir ${APACHE_RUN_DIR}

PidFile ${APACHE_PID_FILE}

Timeout 300

KeepAlive On

MaxKeepAliveRequests 100

KeepAliveTimeout 5

User ${APACHE_RUN_USER}

Group ${APACHE_RUN_GROUP}

HostnameLookups Off

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel warn

IncludeOptional mods-enabled/*.load

IncludeOptional mods-enabled/*.conf

Include ports.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

<Directory /home/amiroof/Projects/amiroo54.github.io/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

AccessFileName .htaccess

<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/amiroof/Projects/amiroo54.github.io/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

apachectl -S 输出

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

error.log 相关错误片段

[Mon Nov 06 20:16:26.580115 2023] [core:error] [pid 13962:tid 140063545972416] (13)Permission denied: [client 127.0.0.1:52216] AH00035: access to / denied (filesystem path '/home/amiroof/Projects') because search permissions are missing on a component of the path

[Mon Nov 06 20:16:26.749283 2023] [core:error] [pid 13962:tid 140063529187008] (13)Permission denied: [client 127.0.0.1:52216] AH00035: access to /favicon.ico denied (filesystem path '/home/amiroof/Projects') because search permissions are missing on a component of the path, referer: http://localhost/

[Mon Nov 06 20:17:47.267389 2023] [core:error] [pid 13961:tid 140063545972416] (13)Permission denied: [client 127.0.0.1:33772] AH00035: access to / denied (filesystem path '/home/amiroof/Projects') because search permissions are missing on a component of the path

我已经尝试过的方法

  • 把/home/amiroof/、/home/amiroof/Projects/、/home/amiroof/Projects/amiroo54.github.io/这些目录的权限都改成了755
  • 用sudo chown amiroof:www-data修改了这些目录的所有者和组
  • 用setfacl -m u:www-data:rx给www-data用户添加了读和执行权限

但不管怎么改,访问http://localhost/还是报权限拒绝的错误,有没有大佬知道问题出在哪啊?

备注:内容来源于stack exchange,提问作者amirmohammad firouzfar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 09:33:00