我的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:07:56.089265 2023] [mpm_event:notice] [pid 13431:tid 140277191919488] AH00489: Apache/2.4.57 (Ubuntu) configured -- resuming normal operations
[Mon Nov 06 20:07:56.089426 2023] [core:notice] [pid 13431:tid 140277191919488] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 06 20:12:46.341517 2023] [mpm_event:notice] [pid 13431:tid 140277191919488] AH00492: caught SIGWINCH, shutting down gracefully
[Mon Nov 06 20:12:46.416245 2023] [mpm_event:notice] [pid 13960:tid 140063562352512] AH00489: Apache/2.4.57 (Ubuntu) configured -- resuming normal operations
[Mon Nov 06 20:12:46.416399 2023] [core:notice] [pid 13960:tid 140063562352512] AH00094: Command line: '/usr/sbin/apache2'
[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
[Mon Nov 06 20:18:05.698161 2023] [mpm_event:notice] [pid 13960:tid 140063562352512] AH00492: caught SIGWINCH, shutting down gracefully
[Mon Nov 06 20:18:05.796597 2023] [mpm_event:notice] [pid 14406:tid 140167944808320] AH00489: Apache/2.4.57 (Ubuntu) configured -- resuming normal operations
我尝试了在网上找到的所有解决方案,但都不起作用。我尝试将权限(、、、、目录)设置为,root
我试过,我试过,但都不起作用。我使用的是 Ubuntu 23.10,Apache 版本 2.4.57。home
user
Projects
amiroo54.github.io
755
sudo chown amiroof:www-data
setfacl -m u:www-data;rx
答案1
您应该更改 的所有者或权限/home/amiroof/Projects
。尝试以下操作来更改目录的所有者(不要忘记-R
):
sudo chown -R www-data:www-data /home/amiroof/Projects
作为@Thomas Ward如上所述,使用上述解决方案,用户amiroof
将无法编辑文件。如果您希望用户能够编辑这些文件,您可以执行以下操作:
sudo chown -R amiroof:www-data /home/amiroof/Projects
sudo chmod -R 775 /home/amiroof/Projects
还有其他方法可以做得更好,但这实际上取决于您的工作流程以及您到底想要实现什么。这是一个可以在您的开发机器上使用的解决方案,但如果您打算将其部署到生产服务器上,请不要这样做。