[英]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.