简体   繁体   English

Apache Rendering 403错误

[英]Apache Rendering 403 error

I'm trying to create a cookbook for installing Wordpress. 我正在尝试创建用于安装Wordpress的食谱。 Everything seems to be ok, except when visiting the sight I get a 403 error. 一切似乎都还不错,除了参观视线时出现403错误。 You don't have permission to access / on this server.

default.rb default.rb

include_recipe 'wp::httpd'
include_recipe 'mariadb'
# include_recipe 'wp::mysql'
include_recipe 'wp::wordpress'

httpd.rb 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 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 模板/默认/ 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>

You need some authz lines in there to allow access to the docroot. 您需要在其中添加一些authz行,以允许访问docroot。 Usually that would be Require all granted in the Directory block for Apache 2.4. 通常,这将Require all granted Apache 2.4在Directory块中Require all granted

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM