简体   繁体   中英

New SubDomain Config for Nginx Throwing an Error: [crit] 29036#0

I have (1) domain and two paths configured: mysite.com blog.mysite.com

I'm trying to configure a wordpress blog on my existing mysite.com nginx server,

mysite.com has a sites-enabled config of:

server {
        listen       80;
        server_name     *.mysite.com;
        root /home/ubuntu/virtualenv/mysite/mysite/myapp/;

        access_log /home/ubuntu/virtualenv/mysite/error/access.log;
        error_log /home/ubuntu/virtualenv/mysite/error/error.log warn;
        connection_pool_size 2048;

        fastcgi_buffer_size 4K;
        fastcgi_buffers 64 4k;

        location /static {
            alias /home/ubuntu/virtualenv/mysite/mysite/myapp/static/;
        }

        location / {
            proxy_pass http://127.0.0.1:8001;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_read_timeout 10;
            proxy_connect_timeout 10;
            add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
        }
    }

blog.mysite.com has a sites-enabled config of:

server {
        listen       80;
        server_name     blog.mysite.com;
        root /home/ubuntu/virtualenv/blog;
        index index.php;

        #### errors
        access_log /home/ubuntu/virtualenv/blog/error/access.log;
        error_log /home/ubuntu/virtualenv/blog/error/error.log warn;
        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;

        fastcgi_buffer_size 4K;
        fastcgi_buffers 64 4k;

        #### locations

        location / {
                try_files $uri $uri/ /index.php?$args;
        }

        location ~ \.php$ {
                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
        }

    }

the error.log file in blog.mysite.com is showing an error of:

2014/01/02 02:50:05 [crit] 29036#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: xx.xxx.xx.xxx, server: blog.mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "blog.mysite.com"

Anyone know why this isn't working? I tried some research, but can't seem to find the solution.

Thank you!

If anyone run's into this error when trying to add a subdomain or domain while configuring nginx with phpfm - follow the steps in this post: https://askubuntu.com/questions/114076/ubuntu-php5-fpm-unix-socket

The gist: sudo vim /etc/php5/fpm/pool.d/www.conf.

Look for the line listen = 127.0.0.1:9000 and change it to something like listen = /var/run/php5-fpm.sock. After doing so, restart PHP FPM:

sudo /etc/init.d/php5-fpm restart

Hope this helps someone :)

Actually it's not really related to subdomains, you just didn't use the right configuration, your fpm was listening to a port instead of a sock file, it wouldn't have worked even without the subdomain,

your main site was working because it was passing to port 8001

proxy_pass http://127.0.0.1:8001;

Your subdomain could have worked if you passed to port 9000

proxy_pass http://127.0.0.1:9000;

But the way you fixed it is better, using sock files is better than port.

Just wanted to explain that it wasn't because of the subdomain.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM