Apache 渲染 403 错误
Apache Rendering 403 error
我正在尝试创建一本用于安装 Wordpress 的说明书。一切似乎都很好,除了在参观景点时出现 403 错误。 You don't have permission to access / on this server.
default.rb
include_recipe 'wp::httpd'
include_recipe 'mariadb'
# include_recipe 'wp::mysql'
include_recipe 'wp::wordpress'
httpd.rb
directory(node[:wp][:app_root])
web_app(node[:wp][:app_name]) do
server_name(node[:wp][:server_name])
docroot(node[:wp][:app_root])
template('vhost.conf.erb')
end
wordpress.rb
ruby_block 'install_wordpress' do
block do
require 'fileutils'
FileUtils.cd node[:wp][:app_root]
system 'wget https://wordpress.org/latest.tar.gz'
system 'tar -xzf latest.tar.gz --strip-components=1 && rm latest.tar.gz'
end
not_if { ::File.exist?(File.join(node[:wp][:app_root], 'wp-settings.php')) }
action :create
end
template("#{node[:wp][:app_root]}/wp-config.php") do
source('wp-config.php.erb')
variables(
db_name: node[:wp][:app_name],
db_user: node[:wp][:app_name],
db_password: node[:wp][:db_password]
)
end
execute 'set_apache_as_owner' do
command "chown #{node['apache']['user']} -R #{node[:wp][:app_root]}"
end
templates/default/vhost.conf.erb
<VirtualHost *:80>
ServerName <%= @params[:server_name] %>
DocumentRoot <%= @params[:docroot] %>
<Directory <%= @params[:docroot] %>>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
LogLevel info
ErrorLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-error.log
CustomLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-access.log combined
</VirtualHost>
您需要在其中添加一些 authz 行以允许访问 docroot。对于 Apache 2.4,通常是 Directory
块中的 Require all granted
。
我正在尝试创建一本用于安装 Wordpress 的说明书。一切似乎都很好,除了在参观景点时出现 403 错误。 You don't have permission to access / on this server.
default.rb
include_recipe 'wp::httpd'
include_recipe 'mariadb'
# include_recipe 'wp::mysql'
include_recipe 'wp::wordpress'
httpd.rb
directory(node[:wp][:app_root])
web_app(node[:wp][:app_name]) do
server_name(node[:wp][:server_name])
docroot(node[:wp][:app_root])
template('vhost.conf.erb')
end
wordpress.rb
ruby_block 'install_wordpress' do
block do
require 'fileutils'
FileUtils.cd node[:wp][:app_root]
system 'wget https://wordpress.org/latest.tar.gz'
system 'tar -xzf latest.tar.gz --strip-components=1 && rm latest.tar.gz'
end
not_if { ::File.exist?(File.join(node[:wp][:app_root], 'wp-settings.php')) }
action :create
end
template("#{node[:wp][:app_root]}/wp-config.php") do
source('wp-config.php.erb')
variables(
db_name: node[:wp][:app_name],
db_user: node[:wp][:app_name],
db_password: node[:wp][:db_password]
)
end
execute 'set_apache_as_owner' do
command "chown #{node['apache']['user']} -R #{node[:wp][:app_root]}"
end
templates/default/vhost.conf.erb
<VirtualHost *:80>
ServerName <%= @params[:server_name] %>
DocumentRoot <%= @params[:docroot] %>
<Directory <%= @params[:docroot] %>>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
LogLevel info
ErrorLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-error.log
CustomLog <%= @node[:apache][:log_dir] %>/<%= @params[:name] %>-access.log combined
</VirtualHost>
您需要在其中添加一些 authz 行以允许访问 docroot。对于 Apache 2.4,通常是 Directory
块中的 Require all granted
。