how to configure nginx
academici opened this issue · 10 comments
Hi! How to configure nginx with php-fpm?
You'll need to use the FastCGI interface, like so:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9007;
include fastcgi.conf;
}
Note that 127.0.0.1:9007
is specific to this build script. It can be configured to your liking https://serversforhackers.com/video/php-fpm-configuration-the-listen-directive
I have error:
[error] 20632#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 128.69.118.169, server: axiom-tech.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9007", host: "axiom-tech.ru"
@vostrikov Have you started the php7-fpm service? sudo service php7-fpm status
root@axiom-tech:/usr/local/php7# service php7-fpm status
● php7-fpm.service - LSB: starts php7-fpm
Loaded: loaded (/etc/init.d/php7-fpm)
Active: active (exited) since Sun 2016-01-03 19:17:29 MSK; 13min ago
Process: 20594 ExecStop=/etc/init.d/php7-fpm stop (code=exited, status=0/SUCCESS)
Process: 20602 ExecStart=/etc/init.d/php7-fpm start (code=exited, status=0/SUCCESS)
@vostrikov Looks good. Not sure why it doesn't work. Can you check the listen
value in /usr/local/php7/etc/php-fpm.d/www.conf
? Here is the source file https://github.com/kasparsd/php-7-debian/blob/master/conf/www.conf
[www]
user = www-data
group = www-data
listen = 127.0.0.1:9007
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
nginx.conf
server {
server_name axiom-tech.ru;
listen 80;
charset UTF8;
set $root_path /var/www/axiomtech.ru/public;
set $fastcgi /usr/local/php7/sbin/;
index index.php;
root $root_path;
access_log /var/log/nginx/axiomtech-access.log;
error_log /var/log/nginx/axiomtech-error.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9007;
include fastcgi_params;
}
}
@vostrikov Which version of Nginx are you running? You might need to use include fastcgi.conf;
instead of include fastcgi_params;
.
Secondly, I don't see $fastcgi
being used anywhere. You can safely remove it.
Nginx version 1.8. fastcgi.conf is created, $fastcgi remove
nginx, php7-fpm was restarted.
[error] 20939#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 128.69.118.169, server: axiom-tech.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9007", host: "axiom-tech.ru"
I have similar issue;
For getting log from php7-fpm daemon:
- sudo start-stop-daemon --stop --pidfile /var/run/php7-fpm.pid --exec /usr/local/php7/sbin/php7-fpm
- sudo start-stop-daemon --start --pidfile /var/run/php7-fpm.pid --exec /usr/local/php7/sbin/php7-fpm
after second command will be some log messages if it's error in here.