Deploy Laravel with capistrano cache files

I have a problem when I try to deploy a Laravel application on an Ubuntu server with Capistrano.

My deployment directory is / var / www / project_stage. When I deploy my project in this directory, everything works fine. My project becomes live, every line of code works as it should.

But when I make changes and deploy a new version of the same project, somehow (I assume), my files get cached and do not respond with the latest version, they still react like the old version, which alrey overwrites.

When I expand the project to another folder (etc: / var / www / project_stage2 instead of / var / www / project _stage) and change the Nginx configuration for maintenance from this folder, it works as it should. But not in the second deployment to the same directory. Therefore, I can say that I can expand to a different directory each time, but I cannot expand it to the same directory twice. He always answers as the first deployment.

Here is what I tried:

  • I checked if the current Capistrano directory is associated with the correct folder that it has.
  • I checked whether the changes that I made would be visible with the new deployment, that they are. Files are completely changed during the new deployment.
  • I checked if Nginx is looking for the correct release directory, it is.
  • I tried to run php artisan cache:clear, route:clear, view:clear, config:cacheand I run composer dump-autoload, too. Nothing worked.
  • I changed the Nginx parameter sendfileto offand restarted, no result.
  • I read a similar problem in this , but this did not work my case.

Here is my deploy.rb:

#deploy_path inherited from staging.rb

lock "~> 3.10.1"

set: application, "project_stage"
set: repo_url, "MY REPO HERE"
set: keep_releases, 10

set: laravel_dotenv_file, "./.env.staging"

namespace: deploy do


    before: updated,: easy do
        on roles (: all) do | host |


            execute: chmod, "-R 777 # {deploy_path} / shared / storage / logs"
            execute: chmod, "-R 777 # {deploy_path} / shared / storage / framework"

        end
    end





    after :finished, :hard do
        on roles(:all) do |host|

        end
    end 

    desc "Build"
    after :updated, :build do
        on roles(:web) do
            within release_path  do
                execute :php, "artisan clear-compiled"
                execute :php, "artisan cache:clear"
                execute :php, "artisan view:clear"
                execute :php, "artisan route:cache"
                execute :php, "artisan config:cache"
            end
        end
    end


end #end deploy namespace


PHP7.0 (FPM unix-), Nginx, Laravel5, Capistrano3 ( /laravel gem), Ubuntu Server 16.4.

+4
1

, , , OPcache opcache.validate_timestamps . validate_timestamps , OPcache . , , .

, :

, php-fpm, cli. Apache mod_php, script, Apache ( HTTP-), cli. , .

+2

Source: https://habr.com/ru/post/1692497/


All Articles