红联Linux门户
Linux帮助

centos6搭建nginx+php+mysql的问题

发布时间:2012-02-28 14:40:19来源:红联作者:fengyun510
在机器上用centos6.1mini版默认安装了centos6系统,然后配置了对应的network的ip和网关,再用yum -y install vsftpd转了FTP等。一切都是正常的,随后按照网上找到的例子:

yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator

自动安装完以上必须的模块软件,用其他机器以IP地址的URL方式访问该cengos机器,出现了nginx欢迎界面,看来nginx是OK的。但是我在对应目录下建立了一个index.php文件,运行关于php的任何代码都提示:
nginx error!
The page you are looking for is temporarily unavailable. Please try again later.
然后我在终端命令行用`php index.php`命令行运行php文件显示结果是OK的。说明php安装也是OK的。
于是我查看nginx错误日志,结果都为这种错误:
server: _, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.1.244"
2012/02/28 19:16:38 [error] 1270#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.55, server: _, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.1.244"
2012/02/28 19:16:41 [error] 1270#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.55, server: _, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.1.244"
访问日志为:
192.168.1.55 - - [28/Feb/2012:19:16:36 +0800] "GET /poweredby.png HTTP/1.1" 304 0 "http://192.168.1.244/index.php" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"
192.168.1.55 - - [28/Feb/2012:19:16:38 +0800] "GET /index.php HTTP/1.1" 502 3695 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"
192.168.1.55 - - [28/Feb/2012:19:16:41 +0800] "GET /index.php HTTP/1.1" 502 3695 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"

附加上我的nginx配置如下:
user www www;

worker_processes 1;

error_log /home/wwwlogs/nginx_error.log crit;

pid /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
}

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

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zone crawler $binary_remote_addr 10m;

server
{
listen 80;
index index.html index.htm index.php;
root /home/www;

location ~ .*\.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location /status {
stub_status on;
access_log off;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
access_log /home/wwwlogs/access.log access;
}
include vhost/*.conf;
}

以上的数据不知道是否足够描述问题,特此请教此问题该如何解决,感谢!
文章评论

共有 6 条评论

  1. 于 2013-12-10 15:07:57发表:

    php-fpm没有起到作用,你的配置文件好像没有转发到FPM的默认端口9000

  2. 于 2013-06-07 16:53:23发表:

    哥们,这个怎么解决的?

  3. bnmluo 于 2012-12-14 17:23:43发表:

    来学习学习

  4. 461020145 于 2012-12-13 09:14:04发表:

    看不明白 学习学习。

  5. moonandlyn 于 2012-05-18 08:48:55发表:

    装lnmp的一建安装 保证每问题

  6. kevinqinan 于 2012-02-28 15:36:56发表:

    不明白,帮顶啊纯属。