简体   繁体   中英

Deploy PHP Files with Capistrano 3 to public_html instead of releases folder

I am new to Capistrano 3.
I want to deploy my php application to public_html folder (i'm using cPanel)

I setup my deploy_to something like this:
set :deploy_to, '/home/username/public_html'
And when i run:
cap production deploy It's successfully upload to my server, but it deployed to releases and current folder instead to root directory which is public_html

My question is, how to make Capistrano upload to my public_html root folder?

You will want to deploy to something like /home/username/code

Then you can create a symbolic link from /home/username/public_html to /home/username/code

The command would look like:

ln -s /home/username/code /home/username/public_html

You can process by deploying files outside the public_html first, then symlink the current release to the public_html fodler as below:

1) In your config/deploy.rb or config/deploy/****.rb files set the deploy_to to be another folder outside the public_html like

set :deploy_to , '/home/username/deploy'

2) In your config/deploy.rb or config/deploy/****.rb files, add a variable with the path to the public_html

set :public_html_path, '/home/username/public_html'

3) Add a custom task release_public_html to symlink the public_html folder after the current release symlink is created

after "deploy:symlink:release", "deploy:symlink:release_public_html"

namespace :deploy do
  namespace :symlink do
    desc "Symlink release to current"
    task :release_public_html do
      on release_roles :all do
    public_html_path = "#{fetch(:public_html_path)}"
        execute :rm, "-rf", public_html_path
        execute :ln, "-s", current_path, public_html_path
      end
    end
  end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM