我有运行 apache2 和 LetsEncrypt SSL 的 Ubuntu 18.04 系统。我还将域名连接到我的服务器。我尝试更改权限和文件夹所有者,但无论我做什么,当我尝试访问我的域时,我仍然会收到 403 Forbidden 错误(顺便说一下,它会自动重定向到 https)。以下是配置文件(我将我的域替换为下面的 sample-domain.eu):
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 All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride All
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
环境变量:
unset HOME
if [ "${APACHE_CONFDIR##/etc/apache2-}" != "${APACHE_CONFDIR}" ] ; then
SUFFIX="-${APACHE_CONFDIR##/etc/apache2-}"
else
SUFFIX=
fi
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2$SUFFIX/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2$SUFFIX
export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
export APACHE_LOG_DIR=/var/log/apache2$SUFFIX
export LANG=C
export LANG
/sites-enabled/000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/sample-domain.eu/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/sites-enabled/sample-domain.eu.conf
<VirtualHost *:80>
ServerName sample-domain.eu
ServerAlias www.sample-domain.eu
ServerAdmin [email protected]
DocumentRoot /var/www/sample-domain.eu/public_html
<Directory /var/www/sample-domain.eu/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/sample-domain.eu-error.log
CustomLog ${APACHE_LOG_DIR}/sample-domain.eu-access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =sample-domain.eu [OR]
RewriteCond %{SERVER_NAME} =www.sample-domain.eu
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
已启用站点/示例域.eu-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName sample-domain.eu
ServerAlias www.sample-domain.eu
ServerAdmin [email protected]
DocumentRoot /var/www/sample-domain.eu/public_html
<Directory /var/www/sample-domain.eu/public_html>
Options -Indexes +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/sample-domain.eu-error.log
CustomLog ${APACHE_LOG_DIR}/sample-domain.eu-access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/sample-domain.eu/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sample-domain.eu/privkey.pem
</VirtualHost>
</IfModule>
另外我在 /var/www/sample-domain.eu/public_html 中有 index.html 文件 编辑:忘了说我已经安装了 phpmyadmin 和 webmin,并且两者都在使用它们的 URL:/phpmyadmin /:10000
答案1
我已经让它工作了,但我不确定这是否是安全的选择。
在/etc/apache2/apache2.conf
文件中,我已将“要求所有拒绝”更改为“要求所有授予”:
<Directory />
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
我不确定为什么将其设置为全部拒绝,因为我没有更改它。但是,服务器现在正在运行,并且不再抛出错误 403。