duanquan4451
duanquan4451
2014-05-19 15:09

nginx虚拟主机:php5-fpm-sock错误

已采纳

I am trying to set a virtual host for a fresh ubuntu/php5.5/nginx installation as such

etc/nginx/sites_available/mydomain.com :

 server {
listen  80 default_server;
root    /home/www/mydomain.com/public/;
index index.php index.html
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
server_name mydomain.com;

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_index index.php;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_read_timeout 240;
    include /etc/nginx/fastcgi_params;
}
 }

etc/hosts :

 127.0.0.1 mydomain.com

symlink in the symlink in the 'sites-enabled' folder :

 sudo ln -s /etc/nginx/sites-available/mydomain.com /etc/nginx/sites-enabled/mydomain.com

the

 service nginx restart

fail and the var/log/nginx/error.log gives

 no port in upstream "php5-fpm-sock" in /etc/nginx/sites-enabled/mydomain.com:12

what can be wrong?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dqy012345 dqy012345 7年前

    The fpm adress path was missing:

     nano /etc/nginx/conf.d/php5-fpm.conf
    

    edit :

    upstream php5-fpm-sock {
        server unix:/var/run/php5-fpm.sock;
    }   
    
    点赞 评论 复制链接分享
  • doushuichong2589 doushuichong2589 7年前

    You are missing php-fpm path setting.

    fastcgi_pass php5-fpm-sock;
    

    You have not point php-fpm to listen. change it to.

    fastcgi_pass 127.0.0.1:9000;
    

    or

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    
    点赞 评论 复制链接分享