doufan6886 2017-02-16 17:02
浏览 174

在一个专用服务器ubuntu上运行多个nginx

Is it possible to run multiple NGINX on a single Dedicated server? I have a dedicated server with 256gb of ram, and I am running multiple PHP scripts on it but it's getting hangs because of memory used with PHP. when I check

free -m

it's not even using 1% of memory.

So, I am guessing its has some to do with NGINX.

Can I install multiple NGINX on this server and use them like

 5.5.5.5:8080,  5.5.5.5:8081,  5.5.5.5:8082

I have already allocated 20 GB memory to PHP, but still not working Properly.

Reason :- NGINX gives 504 Gateway Time-out

  • 写回答

4条回答 默认 最新

  • douwen7331 2017-02-16 17:20
    关注

    I got my Ubuntu / PHP / Nginx server set this way (it actually also runs some Node.js servers in parallel). Here is a configuration example which works fine on a AWS EC2 medium instance (m3).

    upstream xxx {
    #   server unix:/var/run/php5-fpm.sock;
        server 127.0.0.1:9000 max_fails=0 fail_timeout=10s weight=1;
        ip_hash;
        keepalive 512;
    }
    
    server {
        listen 80;
        listen 8080;
        listen 443 ssl;
        #listen [::]:80 ipv6only=on;
    
        server_name xxx.mydomain.io yyy.mydomain.io;
        if ( $http_x_forwarded_proto = 'http' ) {
            return 301 https://$server_name$request_uri;
        }
    
        root /home/ubuntu/www/xxxroot;
        index index.php;
    
        location / {
            try_files $uri $uri/ /index.php;
        }
    
    
        location ~ ^/(status|ping)$ {
            access_log off;
            allow 127.0.0.1;
            #allow 1.2.3.4#your-ip;
            #deny all;
            include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
        }
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
            fastcgi_pass adn;
            #fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
    #fastcgi_param SCRIPT_FILENAME /xxxroot/$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $request_filename;
    #fastcgi_param DOCUMENT_ROOT /home/ubuntu/www/xxxroot;
            # send bad requests to 404
            #fastcgi_intercept_errors on;
            include fastcgi_params;
        }
    
        location ~ /\.ht {
                deny all;
        }
    
    }
    

    Hope it helps,

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能