Настраиваю веб-сервер на виртуальной машине virtualbox. Ubuntu server 14.10 + kubuntu desktop + php5-fpm + nginx.
Nginx отдает 502ю ошибку на *.php файлах.
Через сокеты:
*1 connect() to unix:/var/run/php5-fpm/test.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: test.dev, request: "GET /app_dev.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm/test.sock:", host: "test.dev"
Собственно, файл test.sock не создается. Папка создана, права 777, владельцев пробовал любых (root, www-data, user).
Через TCP:
*7 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: test.dev, request: "GET /app_dev.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:7777", host: "test.dev"
Php-fpm не хочет слушать нужный порт. Пробовал 8080, 7777, 7701, 7711, 9000. Iptables не стоит, телнет нужного порта пишет "connection refused", в
netstat -nap | grep 8080,
lsof -i :8080,
lsof -i :8080 и
netstat -nltp пусто.
/etc/nginx/nginx.conf:
spoileruser ivan ivan;
worker_processes 1;
worker_rlimit_nofile 8192;
worker_priority -5;
pid /run/nginx.pid;
timer_resolution 100ms;
events {
worker_connections 768;
use epoll;
# 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;
charset utf-8;
##
# 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/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
##
server {
listen 80 default_server;
server_name 127.0.0.1;
#access_log off;
log_not_found off;
return 403;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites/*;
}
#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;
# }
#}
/etc/nginx/sites/test.conf:
spoilerserver {
listen 80;
server_name test.dev;
root /home/ivan/sites/test/web;
location / {
# try to serve file directly, fallback to app_prod.php
try_files $uri /app_prod.php$args;
}
# DEV
# This rule should only be placed on your development environment
# In production, don't include this and don't deploy app_dev.php or config.php
location ~ ^/(app_dev|app_test|config|_intellij_phpdebug_validator)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm/test.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_read_timeout 100m;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
# PROD
location ~ ^/app_prod\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm/test.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
# Prevents URIs that include the front controller. This will 404:
# http://test.dev/app_prod.php/some-path
# Remove the internal directive to allow URIs like this
internal;
}
location ~* \.(?:jp?g|gif|png|ico|svg|css|js|swf|zip|tar|tgz|gz|rar|bz2|doc|docx|xls|xlsx|ppt|pptx|exe|msi|txt|mp3|mp4|mkv|mpg|mov|fla|eot|otf|ttf|woff)$ {
expires max;
access_log off;
log_not_found on;
try_files $uri =404;
}
error_log /home/ivan/sites/test/app/logs/nginx_error.log;
access_log /home/ivan/sites/test/app/logs/nginx_access.log;
}
Почему так происходит? Почему php-fpm не создает файл и не хочет слушать порт?
UPD: Снес всю систему, поставил ubuntu-server и xubuntu с нуля, установил nginx+php-fpm и запустил их со стандартными конфигами — на /var/www/html/index.php 502-я ошибка, php-fpm не создает .sock-файл.
UPD 2: В таск-менеджере ситуация следующая: все процессы php5-fpm (php5-fpm-checkconf, php5-fpm --fpm-config /etc/php5/fpm/php-fpm.conf -t, php5-fpm --nodaemonize --fpm-config /etc/php5/fpm/php-fpm.conf) хаотично перезапускаются (каждый процесс живет не больше секунды, запускается и сразу же умирает), всего их штук 5-7.
В чем может быть проблема? Почему процессы сразу же умирают и ничего не пишут в логи? В логах кстати появилось пару ошибок после того как выставил log_level = debug, но они все никак не связаны с проблемой и пропали после фиксов.
UPD 3: Проблема решена установкой php5-fpm другой версии из другого репозитория.