I installed nginx on my Lubuntu 13.04 32 bit using:
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
After it I disabled apache:
sudo kill $(pidof apache2)
sudo update-rc.d -f apache2 remove
and I edited the nginx.conf, that now is:
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;
}
}
}
So I started nginx, I wrote a test.php script inside the html directory with only
echo 'OK!';
and I opened it inside the browser, but it doesn't work. The error is:
[error] 2886#0: *1 connect() failed (111: Connection refused) while
connecting to upstream, client: 127.0.0.1, server: localhost, request:
"GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host:
"localhost"
php5-fpm seems to be already started, since if I try sudo php5-fpm, I get this error:
ERROR: An another FPM instance seems to already listen on /var/run/php5-fpm.sock
Answer
Your PHP-FPM installation is set up to use sockets and not TCP.
Change this line:
fastcgi_pass fastcgi_pass 127.0.0.1:9000;
To: fastcgi_pass unix:/var/run/php5-fpm/php5-fpm.sock;
Alternatively you can modify your nginx.conf file's listen =
to use a port instead of the socket.
No comments:
Post a Comment