nginx配置rafter替换apache2

时间:2013-06-18 17:52:40

标签: nginx

我在笔记本电脑上运行apache2作为网络服务器。然后我决定转移到nginx。

- 安装nginx - php(fastcgi - fpm)而不删除apache

- 使用下一个规则配置/ etc / nginx / site-enabled / default

root /var/www;
index index.html index.htm index.php;

    location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    deny all;
}
location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

    # With php5-cgi alone:
    fastcgi_pass 127.0.0.1:9000;
    # With php5-fpm:
    #fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

从浏览器中键入localnig localhost,并禁止403

键入127.0.0.1:9000此网页不可用

12.0.0.1禁止

我看到它的权限问题,但我运行chmod 777 var / www 和运行显示网站时的apache2

那么我的配置有什么问题或者我错过了什么?

1 个答案:

答案 0 :(得分:0)

如果以上是您默认文件的唯一内容,那么我想知道为什么nginx甚至会启动。您必须创建一个服务器块:

server {
  listen 80;
  server_name _;
  root /var/www;
  index index.html index.htm index.php;

  location /doc/ {
    alias /usr/share/doc;
    autoindex on;
    allow 127.0.0.1;
    deny all;
  }

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_pass 127.0.0.1:9000;
  }
}

在(重新)开始之前,请务必使用nginx -t检查您的配置。