[英]Nginx 1.4.6 throwing 503 errors
Nginx 1.4.6 抛出 503 错误
我在 digitalocean droplet - nginx/1.4.6 (Ubuntu) 上配置了 2 个网站(wordpress 和 laravel v4)。
这两个网站通常都运行良好且快速。
但是在laravel网站保存任何数据时,它会抛出503错误。 并且在wordpress中它没有彻底解决503错误,但是在保存任何帖子或任何数据时需要花费很长时间来响应大约1-3分钟。
两个站点的虚拟主机配置如下。
server {
listen 80;
listen 443 ssl;
root /var/www/domain1.com/public_html;
index index.php index.html index.htm;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
# Make site accessible from http://localhost/
server_name domain1.com www.domain1.com;
access_log off;
#GZIP Configuration
gzip on;
gzip_min_length 100;
gzip_comp_level 3;
gzip_types text/plain;
gzip_types text/css;
gzip_types text/javascript;
gzip_disable "msie6";
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
if ($host !~* ^www\.)
{
rewrite ^/(.*)$ http://www.$host/$1 permanent;
}
proxy_read_timeout 300;
}
error_page 404 /error.html;
location ^~ /error.html {
rewrite ^/.* http://www.domain1.com permanent;
}
location ~* \.(css|js|jpg|png|gif)$ {
access_log off;
expires 1M;
add_header Pragma public;
add_header Cache-Control public;
add_header Vary Accept-Encoding;
}
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 600s;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我还检查了错误日志,没有发现任何重要的东西。
请指导我,为什么 Laravel v4 网站显示 503 错误,以及为什么 wordpress 网站在保存数据时很慢。
503 表示服务没有响应。 我猜你会因为 laraval 使用过多的资源(即内存)而超时,可能会在你的 droplet 上最大化。
从您的配置中,我可以看到您有一个 php-fpm 套接字,但决定通过端口 9000 使用 php。
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
我建议使用 2 个不同的池配置 php-fpm,一个用于 wordpress,另一个用于 laravel,然后让它们设置为侦听每个池具有不同设置的不同套接字,即 wordpress 可以有php_value[memory_limit] = 128M
和 laravel php_value[memory_limit] = 64M
。 虽然这只是一个想法,因为每个游泳池都有很多设置。
此外,您的配置有非常慷慨的超时设置:
proxy_read_timeout 300
fastcgi_read_timeout 600s
等待 5 或 10 分钟的响应是非常不寻常的。
我认为最好的方法是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.