[英]Run multiple nginx on one dedicated server ubuntu
是否可以在一台專用服務器上運行多個NGINX? 我有一個256gb的ram專用服務器,並且正在其上運行多個PHP腳本,但是由於與PHP一起使用的內存而使其掛起。 當我檢查
free -m
它甚至沒有使用1%的內存。
因此,我想它與NGINX有關。
我可以在該服務器上安裝多個NGINX並像
5.5.5.5:8080, 5.5.5.5:8081, 5.5.5.5:8082
我已經為PHP分配了20 GB內存,但是仍然無法正常工作。
原因:-NGINX給出了504網關超時
PHP或NGINX配置錯誤
如果滿足某些條件,則可以在同一服務器上運行多個Nginx實例。 但這不是您應尋找的解決方案(這也可能根本無法解決您的問題)。
我以這種方式設置了Ubuntu / PHP / Nginx服務器(它實際上還並行運行一些Node.js服務器)。 這是一個配置示例,可以在AWS EC2介質實例(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;
}
}
希望能幫助到你,
我認為您快要超時了。 您的PHP腳本接縫將持續很長時間。
檢查以下內容:
max_execution_time
www.conf
中的request_terminate_timeout
http
部分或location
部分的fastcgi_read_timeout
。 Nginx被設計為更多用作反向代理或負載平衡器,而不是控制應用程序邏輯和運行php腳本。 運行每個執行php的多個nginx實例並不能真正發揮服務器應用程序的優勢。 作為替代方案,我建議使用nginx在一個或多個apache實例之間進行代理,該實例更適合執行繁重的php腳本。 http://kbeezie.com/apache-with-nginx/包含有關使apache和nginx一起良好玩耍的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.