将 Apache 配置从 2.2 迁移到 2.4
Migrating Apache configuration from 2.2 to 2.4
我正在使用此 Apache conf 锁定 /wp-admin/ 区域 login/password,但我不确定我的新 Apache 2.4 conf 部分是否是正确,有人可以帮助我吗?
<Directory "/opt/bitnami/apps/wordpress/htdocs/wp-admin">
AuthType Basic
AuthName "Restricted files"
AuthUserFile "/opt/bitnami/apache2/wordpress_users"
Require valid-user
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Deny,Allow
Deny from all
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
<Files admin-ajax.php>
Require all granted
</Files>
</IfModule>
</Directory>
您修改了什么 Apache 配置文件?你是在文件/opt/bitnami/apps/wordpress/conf/htaccess.conf中引入改动吗?如果您使用其他文件,请使用此文件。
AuthUserFile "/opt/bitnami/apache2/wordpress_users"
这个文件存在吗?您是使用 htpasswd 创建的吗?请在下面的 link 中找到完整的文档:
https://httpd.apache.org/docs/2.4/mod/mod_authn_file.html
我还要添加以下行来解释为什么您不允许访问某些文件:
ErrorDocument 403 "For security reasons, this file is not accessible."
记得通过运行命令重新启动Apache以加载所有更改:
sudo /opt/bitnami/ctlscript.sh restart apache
我正在使用此 Apache conf 锁定 /wp-admin/ 区域 login/password,但我不确定我的新 Apache 2.4 conf 部分是否是正确,有人可以帮助我吗?
<Directory "/opt/bitnami/apps/wordpress/htdocs/wp-admin">
AuthType Basic
AuthName "Restricted files"
AuthUserFile "/opt/bitnami/apache2/wordpress_users"
Require valid-user
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Deny,Allow
Deny from all
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
<Files admin-ajax.php>
Require all granted
</Files>
</IfModule>
</Directory>
您修改了什么 Apache 配置文件?你是在文件/opt/bitnami/apps/wordpress/conf/htaccess.conf中引入改动吗?如果您使用其他文件,请使用此文件。
AuthUserFile "/opt/bitnami/apache2/wordpress_users"
这个文件存在吗?您是使用 htpasswd 创建的吗?请在下面的 link 中找到完整的文档:
https://httpd.apache.org/docs/2.4/mod/mod_authn_file.html
我还要添加以下行来解释为什么您不允许访问某些文件:
ErrorDocument 403 "For security reasons, this file is not accessible."
记得通过运行命令重新启动Apache以加载所有更改:
sudo /opt/bitnami/ctlscript.sh restart apache