歡迎您光臨本站 註冊首頁

求幫助 ubuntu10.04 讓Nginx支持PHP(FastCGI)失敗

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

求幫助 ubuntu10.04 讓Nginx支持PHP(FastCGI)失敗

參考:http://dai-666600.blog.163.com/b ... 703620106217563353/
         http://b.gkp.cc/2010/10/12/setup-nmp-on-ubuntu-1010/
         http://abloz.com/2010/09/27/ubun ... -configuration.html

系統環境是ubuntu10.04LTS,步驟如下

apt-get install nginx



apt-get install mysql-server mysql-client mysql-common mysql-admin


然後安裝PHP5 php5-fpm
在安裝之前,我們要先編輯軟體安裝源,默認的情況下,php5-fpm的軟體源未在列表中。
sudo vi /etc/apt/sources.list
我在最末行加上如下兩行:
deb http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
deb-src http://ppa.launchpad.net/brianmercer/php/ubuntu lucid main
因為這兩個站點下載需要密鑰,我的電腦上默認沒有安裝,所以需要輸入如下命令:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8D0DC64F  ***這裡的o為數字零
安裝完后就 sudo apt-get update


apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json php5-suhosin php5-common php-apc php5-dev


apt-get install php5-fpm php5-cgi


問題描述:火狐訪問http://ip/index.html  正常顯示Welcome to nginx!web3 /var/www/nginx-default/index.html
                        訪問http://ip/index.php  網頁顯示為一個白板,  有時候顯示<?php phpinfo(); ?> 文本內容

不知道是nginx配置錯誤還是php、phpfcgi、安裝錯誤?

希望能得到幫助,謝謝大家



進程和配置文件信息如下:

root@ubuntu:~# ps -ef | grep php
root       890     1  0 09:00 ?        00:00:02 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   891   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   892   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   893   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   894   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   895   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   896   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   897   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   898   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   899   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
www-data   900   890  0 09:00 ?        00:00:00 /usr/bin/php5-fpm --fpm-config /etc/php5/fpm/php5-fpm.conf
root      1215  1197  0 11:10 pts/0    00:00:00 grep --color=auto php
root@ubuntu:~# ps -ef | grep nginx
root       810     1  0 08:59 ?        00:00:00 nginx: master process /usr/sbin/nginx
www-data   811   810  0 08:59 ?        00:00:00 nginx: worker process
root      1228  1197  0 11:10 pts/0    00:00:00 grep --color=auto nginx
root@ubuntu:~# grep -v "^$" /etc/nginx/nginx.conf | grep -v "#"
user www-data;
worker_processes  1;
error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       /etc/nginx/mime.types;
    access_log  /var/log/nginx/access.log;
    sendfile        on;
    keepalive_timeout  65;
    tcp_nodelay        on;
    gzip  on;
    gzip_disable "MSIE \.(?!.*SV1)";
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
  upstream nginx_server_pool {
      server 192.168.0.121 max_fails=2 fail_timeout=30s;
    }
   server {
   listen 80;
   server_name 192.168.0.121;
      location / {
     proxy_pass http://nginx_server_pool;
     }
    }
}
root@ubuntu:~# grep -v "^$" /etc/nginx/sites-available/default | grep -v "#"
server {
        listen   80 default;
        server_name  localhost;
        access_log  /var/log/nginx/localhost.access.log;
        location / {
                root   /var/www/nginx-default;
                index index.php  index.html index.htm;
        }
        location /doc {
                root   /usr/share;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }
        location /images {
                root   /usr/share;
                autoindex on;
        }
        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /var/www/nginx-default/$fastcgi_script_name;
                include fastcgi_params;
        }
}
root@ubuntu:~# grep -v "^$" /etc/nginx/fastcgi_params | grep -v "#"
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_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;
fastcgi_param  REDIRECT_STATUS    200;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  PATH_INFO          $fastcgi_script_name;
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;
fastcgi_intercept_errors on;
root@ubuntu:~# grep -v "^$" /var/www/nginx-default/ | grep -v "#"
50x.html    index.html  index.php   
root@ubuntu:~# grep -v "^$" /var/www/nginx-default/index.html | grep -v "#"
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body bgcolor="white" text="black">
<center><h1>Welcome to nginx!web3 /var/www/nginx-default/index.html</h1></center>
</body>
</html>
root@ubuntu:~# grep -v "^$" /var/www/nginx-default/index.php | grep -v "#"
<?php phpinfo(); ?>
root@ubuntu:~#

[火星人 ] 求幫助 ubuntu10.04 讓Nginx支持PHP(FastCGI)失敗已經有501次圍觀

http://coctec.com/docs/service/show-post-13167.html