0

我有一个意外的行为,Laravel执行的代码与更新的代码不同。似乎 PHP7.0-FPM 或其他组件将其保存在内存中,只有硬重启机器才会刷新代码。

即我有一个文件“SomeController.php”

echo 'version1';

执行 git pull 后,新文件现在是:

echo 'version2';//verified via ssh that this is the actual content 

但是在运行代码输出时仍然显示version1

我试过了:

sudo service php7.0-fpm reload //no success

sudo service php7.0-fpm restart //no success

sudo service nginx restart //no success

sudo reboot //the only thing that works

这绝对是某种代码缓存问题,因为每次硬重启都能解决这个问题。

据我了解sudo service php7.0-fpm reload应该做的工作。

任何建议将不胜感激。

更新 - 每个评论的 nginx 配置

nginx.conf 内容

user www-data;
pid /run/nginx.pid;
worker_processes 2;

events {
    worker_connections 768;
    # multi_accept on;
}

http {
    sendfile off;#on
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 200;#65
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # 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;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # Virtual Host Configs
    ##

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;

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

//在站点可用/启用下 - 设置是

server {
    listen 80;
    server_name my.domain.com;
    return 301 https://$host$request_uri;
}
server {
    server_name my.domain.com;
    listen 443 ssl;
//ssl certificate info here (using lets encrypt)
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
large_client_header_buffers 2 1k;

client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;

gzip             on;
gzip_comp_level  2;
gzip_min_length  1000;
gzip_proxied     expired no-cache no-store private auth;
gzip_types       text/plain application/x-javascript text/xml text/css application/xml;

access_log off;

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
    expires 365d;
}

root /var/www/html/prod/public;
    index index.php index.html index.htm;

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;

    location ~ /.well-known {
        allow all;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?_url=/$1;
    }

    # server_name localhost;
    location / {
        # laravel's pretty urls
        try_files $uri $uri/ /index.php?$query_string;
    }

     location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}
4

0 回答 0