I'm using an Nginx server, never worked with one before so I apologize if I've missed something stupid but I'm new to all of this.
In my error.log I have:
[error] 2105#0: *87 connect() failed (111: Connection refused) while connecting to upstream, client: 86.58.251.66, server: premium.bookboon.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "premium.bookboon.com"
And I'm not sure why this error occurs. Here is my nginx.conf:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
I've seen a lot of these issues being solved with by fixing some php-fpm option but the server I'm working with doesn't appear to use it, a quick find / -name "php-fpm"
returns nothing so I'm at a bit of loss here.
/sites-enabled/default:
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name premium.bookboon.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
root /var/www/premium/web;
server_name premium.bookboon.com;
ssl_certificate /etc/ssl/certs/premium.bookboon.com_bundle.crt;
ssl_certificate_key /etc/ssl/private/premium.bookboon.com.key;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|config|test)\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_param ENVIRONMENT "prod";
}
error_log /var/log/nginx/premium_error.log;
access_log /var/log/nginx/premium_access.log;
}
Any help would be greatly appreciated.
Nginx does, by itself not contain any components to execute PHP code. It needs PHP-FPM for that.
Your nginx is configured to use PHP-FPM, but (as you already said) PHP-FPM is not installed.
If you want to run PHP scripts, you need to install and configure PHP-FPM. Installation is done with apt-get install php5-fpm
on Debian-based systems. You will usually also have to install several of the php5-*
library packages. (Depends on the application you want to run, so either read its docs or try executing it and look for error messages.)
Configuring PHP-FPM is not complicated, the default should work. Note that your nginx is configured to communicate with PHP-FPM through a network socket! Make sure that in the file /etc/php5/fpm/pool.d/www.conf
the listen
parameter is configured with the correct combination of IP address and port, eg listen = 127.0.0.1:9000
.
You will usually also have to make a few edits in php.ini
, but this is very specific to your use case and goes beyond this topic.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.