Laravel 5.2 + Nginx + PHP7 + PHP7.0-FPM - 执行的代码与硬盘

时间:2017-03-11 04:02:32

标签: php laravel nginx opcache fpm

我遇到意外行为,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应该做的工作。

任何建议都将不胜感激。

UPDATE - 每条评论的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/*;
}

//在sites-available / 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;
        }
}

0 个答案:

没有答案