·

* 安装pcre

链接: https://pan.baidu.com/s/1z0VShe7WRfQp64-zWeQ-rg 提取码: vm44 复制这段内容后打开百度网盘手机App,操作更方便哦

* 安装nginx

http://tengine.taobao.org/download.html

wget http://tengine.taobao.org/download/tengine-2.1.1.tar.gz
tar xvzf tengine-2.1.1.tar.gz -C .
cd tengine-2.1.1
./configure --prefix=/opt/nginx
make
sudo make install
 

* 查看php-fpm

$ sudo lsof -i:9000
[sudo] password for mzh: 
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 1732   root    6u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 1733 apache    0u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 1734 apache    0u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 1735 apache    0u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 1736 apache    0u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 1737 apache    0u  IPv4  24467      0t0  TCP localhost:cslistener (LISTEN)

ok

php-fpm进程找不到SCRIPT_FILENAME配置的要执行的.php文件,php-fpm返回给nginx的默认404错误提示

 

假设项目入口文件 /www/index.php 

对应nginx配置

fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;

 

nginx.conf


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}

# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
#    load ngx_http_fastcgi_module.so;
#    load ngx_http_rewrite_module.so;
#}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8086;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # location / {
        #     root   html;
        #     index  index.html index.htm;
        # }

        location / {
            root   /www;
            index  index.php index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
           root           html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
 	       fastcgi_param  SCRIPT_FILENAME  /www/$fastcgi_script_name;
           include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

FastDFS:·

 

另一种错误:

nginx 404 路由被当做静态文件访问

location / {
         if (!-e $request_filename) {
         rewrite  ^(.*)$  /index.php?s=$1  last;
          break;
        }
        }

url 重写隐藏入口文件