403 尝试访问 Nginx 时被禁止

Axi*_*iol 3 nginx wordpress http-status-code-403

我刚刚有了一台新服务器,想尝试一些其他的东西。喜欢 Nginx 而不是 Apache。

所以,安装了nginx,得到了欢迎页面,安装php5-fpm并下载了一个 Wordpress 试一试。

但是,403 Forbidden当我尝试去地址时,我仍然得到了一个...

这是 conf 文件:

server {
  listen   80;
  server_name  localhost;
  access_log  /var/log/nginx/axiol.access.log;
  error_log  /var/log/nginx/axiol.error.log error;

  root  /usr/share/nginx/axiol;

  location ~ .php$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/axiol$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_param  QUERY_STRING     $query_string;
    fastcgi_param  REQUEST_METHOD   $request_method;
    fastcgi_param  CONTENT_TYPE     $content_type;
    fastcgi_param  CONTENT_LENGTH   $content_length;
    fastcgi_intercept_errors        on;
    fastcgi_ignore_client_abort     off;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
  }

  rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  try_files $uri $uri/ /index.php?$args;
}
Run Code Online (Sandbox Code Playgroud)

我已经检查了axiol文件夹的chmod 。

任何的想法 ?

Saš*_*ašo 8

您在 php 位置中犯了一个错误。您需要转义,.因为它在正则表达式中以其他方式使用。

  location ~ \.php$ {
Run Code Online (Sandbox Code Playgroud)

编辑:

您还应该在下面添加以下内容server

    index  index.html index.htm index.php;
Run Code Online (Sandbox Code Playgroud)

如果没有指定文件,则需要自动传递 index.php(如果 index.html 和 index.htm 不存在)。