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,

    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题