免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1277 | 回复: 0
打印 上一主题 下一主题

求帮助 ubuntu10.04 让Nginx支持PHP(FastCGI)失败 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-22 10:58 |只看该作者 |倒序浏览
参考: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 [1-6]\.(?!.*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:~#
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP