我在我的Lubuntu 13.04 32位上安装了nginx,使用:
sudo apt-get install php5-fpm sudo apt-get install mercurial libpcre3-dev libssl-dev hg clone -r stable-1.4 http://hg.nginx.org/nginx nginx cd nginx auto/configure --with-http_ssl_module make sudo make install
之后,我禁用了apache:
sudo kill $(pidof apache2) sudo update-rc.d -f apache2 remove
我编辑了nginx.conf,现在是:
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; index index.html index.php; location / { root html; index index.html index.php; } # 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 /scripts$fastcgi_script_name; include fastcgi_params; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
所以我开始了nginx,我只用html编写了一个test.php脚本
<?php echo 'OK!';
我在浏览器中打开它,但它不起作用。 错误是:
连接到上游时,客户端:127.0.0.1,服务器:本地主机,请求:“GET /test.php HTTP / 1.1”,上游:“错误2886#0:* 1连接()失败fastcgi://127.0.0.1:9000“,主机:”localhost“
php5-fpm似乎已经开始,因为如果我尝试sudo php5-fpm,我得到这个错误:
ERROR: An another FPM instance seems to already listen on /var/run/php5-fpm.sock
您的PHP-FPM安装设置为使用套接字而不是TCP。
改变这一行:
fastcgi_pass fastcgi_pass 127.0.0.1:9000;
要: fastcgi_pass unix:/var/run/php5-fpm/php5-fpm.sock;
或者,您可以修改您的nginx.conf文件的listen =使用端口而不是套接字。