【问题标题】:Website hosted on Virtual Machine on Homestead doesn't respond after couple of minutes托管在 Homestead 上的虚拟机上的网站在几分钟后没有响应
【发布时间】:2017-10-05 06:51:06
【问题描述】:

我使用Homestead box 作为我的开发环境。作为虚拟机提供商,我使用VirtualBox。我的网站经常挂起,直到我重新加载 vagrant 才响应。有人有同样的问题吗?

我注意到当我在客户端取消请求时它会挂起。如果我不这样做,那么网站正在工作。

ngixn.conf

 worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
user vagrant;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##
       {
        sendfile on;
        tcp_nopush on;
}       tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
                                                              1,1           To









        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}

网站服务器

server {
listen 80;
listen 443 ssl http2;
server_name site.dev;
root "/home/vagrant/Projects/GUIRebuild/public";

index index.html index.htm index.php;

charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/site.dev-error.log error;

sendfile off;

client_max_body_size 100m;


location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

location ~ /\.ht {
    deny all;
}

ssl_certificate     /etc/nginx/ssl/site.dev.crt;
ssl_certificate_key /etc/nginx/ssl/site.dev.key;

}

错误日志

    2017/10/06 05:25:48 [error] 3839#3839: *521 upstream timed out (110: Connection
timed out) while reading response header from upstream, client: 192.168.10.1, se
rver: devinix.dev, request: "GET /api/auth_state HTTP/1.1", upstream: "fastcgi:/
/unix:/var/run/php/php7.1-fpm.sock", host: "devinix.dev", referrer: "http://devi
nix.dev/"
2017/10/06 05:27:02 [error] 3839#3839: *523 upstream timed out (110: Connection
timed out) while reading response header from upstream, client: 192.168.10.1, se
rver: devinix.dev, request: "GET /api/auth_state HTTP/1.1", upstream: "fastcgi:/
/unix:/var/run/php/php7.1-fpm.sock", host: "devinix.dev", referrer: "http://devi
nix.dev/"

我是 Windows 用户,机器在 Ubuntu 上运行。

【问题讨论】:

  • 尝试添加config.vm.provider "virtualbox" do |v| v.memory = 2048 v.cpus = 2 end 看看是否有帮助
  • 它已经使用了2048个内存和4个cpus。我不知道是它的nginx问题还是vm。
  • 在 vm 中使用 htop 看看发生了什么
  • 一切都很好,没有过载,磁盘也很好。一定是nginx的问题,当我发送太多请求时它会挂起。但是我可以ping它而不会中断。

标签: nginx vagrant virtualbox homestead


【解决方案1】:

我确实将我的宅基地版本从 3.1 升级到了 4.0,现在它运行良好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-10
    • 2021-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    相关资源
    最近更新 更多