duanbi7204 2014-12-08 11:13
浏览 120

Apache迁移到Nginx - connect()失败(111:连接被拒绝),同时连接到上游

I recently migrated a php (codeigniter) site from apache to nginx, there is a nodejs and html site already running on my nginx server.

I am seeing this error in error log of apache

connect() failed (111: Connection refused) while connecting to upstream, client: X.X.X.X, server: contextsdk-api.semusi.com, request: "POST /v1/Data HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "sdk-api.XXX.com"

Here is my nginx configuration

upstream api {
    server 127.0.0.1:9000;
}
server {
        listen   80;

        root /home/azureuser/contextsdkapi;
        server_name contextsdk-api.semusi.com;

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

        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; }
            expires off; ## Do not cache dynamic content
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param MAGE_RUN_CODE default;
            fastcgi_param MAGE_RUN_TYPE store;
            include fastcgi_params;
        }

         location ~/\.ht {
        deny all;
    }

}

Update -

I changed my nginx configuration, location section to

 location ~ .php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }

Now i am getting the error as -

connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类