nginx php-fpm

开源中国刘德华 发布于 2016/10/10 14:01
阅读 305
收藏 0

我在conf.d中建了一个php-test.conf文件,内容如下

# php测试的配置文件,看看php配置是否成功

server {

    listen      80;

    server_name 120.24.176.190;

    root        /mnt/dev/php;

    location / {

        index   index.html index.php;

    #fastcgi_param script_filename $document_root$fastcgi_script_name;

    }

    location ~* \.(gif|jpg|png)$ {

        expires 30d;

    }

    

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    location ~ \.php$ {

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }

}


nginx是1.10版本的,php-fpm和nginx都是通过yum安装的

要访问的文件权限如下

[root@iZ94pjjvvshZ php]# ll

总用量 4

-rwxrwxrwx 1 root root 20 10月 10 13:35 phpinfo.php


访问120.24.176.190/phpinfo.php 出错,File Not Found

nginx的error.log为:

2016/10/10 13:55:20 [error] 21188#0: *47 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 180.173.67.62, server: 120.24.176.190, request: "GET /phpinfo.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "120.24.176.190"


user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;


# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;


events {
    worker_connections 1024;
}


http {
    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  /var/log/nginx/access.log  main;


    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;


    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;


    include /etc/nginx/conf.d/*.conf;


    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;


        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        location / {
        }


        error_page 404 /404.html;
            location = /40x.html {
        }


        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }


}

加载中
0
太阳黑子
太阳黑子

/etc/nginx/nginx.conf内容贴出来看看

把phpinfo.php放在/usr/share/nginx/html目录访问看看正常不

开源中国刘德华
开源中国刘德华
回复 @太阳黑子 : 这个不行啊,php要走fpm,而你说的那个目录是静态文件放置的目录
太阳黑子
太阳黑子
回复 @橙子先生 : 把phpinfo.php放在/usr/share/nginx/html目录,访问http://120.24.176.190/phpinfo.php看看正常不
开源中国刘德华
开源中国刘德华
我已经把配置贴到问题里了
返回顶部
顶部