使用 PHP 的 Capistrano

发布于 2025-01-07 13:34:43 字数 3267 浏览 3 评论 0原文

我正在尝试将 helloworld 站点从本地计算机部署到服务器。我已经安装了 Ruby、Rails 和 Capistrano。获得食谱后,我输入“cap deploy:setup”命令并收到以下错误

/usr/lib/ruby/1.8/capistrano/configuration/variables.rb:122:in method_missing':未定义的局部变量或方法primary' for

(NameError) from ./config/deploy.rb:19:in `load' from

/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:172:in load_from_file' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in加载' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in 加载'自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:ineach' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in 从 Capfile:4:in 加载'从 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:172:in load_from_file' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in加载' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in 加载'自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:ineach' 来自 /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in 从 /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in 加载'load_recipes' 来自 /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in 来自 /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in 的 eachload_recipes' 来自 /usr/lib/ruby/1.8/capistrano/cli/execute.rb:30:in 执行!'来自 /usr/lib/ruby/1.8/capistrano/cli/execute.rb:14:in从 /usr/bin/cap:4 执行

以下是我的deploy.rb 文件内容。

set :application, "testapp"
set :repository,  "<url of git repo>"
set :deploy_to, "var/www/html/testapp"
set :document_root, "var/www/html/testapp/current"

set :scm, :git
set :scm_username, "MyUserName"
set :scm_password, "MyPassword"
set :scm_checkout, "clone"
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

set :user, "<server's user name>"
set :password, "<server's password>"
set :use_sudo, false
set :ssh_options, {:forward_agent => true}

role :web, "<server's IP>"                          # Your HTTP server, Apache/etc
role :app, "<server's IP>"                          # This may be the same as your `Web` server
role :db,  "<server's IP>", primary => true # This is where Rails migrations will run

# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts

# namespace :deploy do
#   task :start {}
#   task :stop {}
#   task :restart, :roles => :app, :except => { :no_release => true } do
#     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
#   end
# end
namespace :deploy do
    task :update do
        transaction do
            update_code
            symlink
        end
    end

    task :finalize_update do
        transaction do          
        end
    end

    task :symlink do
        transaction do
            run "ln -nfs #{current_release} #{deploy_to}/#{current_dir}"
            run "ln -nfs #{deploy_to}/#{current_dir} #{document_root}"
        end
    end

    task :migrate do
    end

    task :restart do
    end
end

I am trying to deploy a helloworld site from my local machine to a server. I have installed Ruby, Rails and Capistrano. After having a recipe I type this "cap deploy:setup" command and get following error

/usr/lib/ruby/1.8/capistrano/configuration/variables.rb:122:in
method_missing': undefined local variable or methodprimary' for

(NameError) from ./config/deploy.rb:19:in `load' from

/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:172:in
load_from_file' from
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in
load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
load' from
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
each'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
load' from Capfile:4:inload' from
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:172:in
load_from_file' from
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:89:in
load'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
load' from
/usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
each'
from /usr/lib/ruby/1.8/capistrano/configuration/loading.rb:86:in
load' from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in
load_recipes' from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in
each' from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:64:in
load_recipes' from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:30:in
execute!' from /usr/lib/ruby/1.8/capistrano/cli/execute.rb:14:in
execute' from /usr/bin/cap:4

Following is my deploy.rb file contents.

set :application, "testapp"
set :repository,  "<url of git repo>"
set :deploy_to, "var/www/html/testapp"
set :document_root, "var/www/html/testapp/current"

set :scm, :git
set :scm_username, "MyUserName"
set :scm_password, "MyPassword"
set :scm_checkout, "clone"
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

set :user, "<server's user name>"
set :password, "<server's password>"
set :use_sudo, false
set :ssh_options, {:forward_agent => true}

role :web, "<server's IP>"                          # Your HTTP server, Apache/etc
role :app, "<server's IP>"                          # This may be the same as your `Web` server
role :db,  "<server's IP>", primary => true # This is where Rails migrations will run

# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts

# namespace :deploy do
#   task :start {}
#   task :stop {}
#   task :restart, :roles => :app, :except => { :no_release => true } do
#     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
#   end
# end
namespace :deploy do
    task :update do
        transaction do
            update_code
            symlink
        end
    end

    task :finalize_update do
        transaction do          
        end
    end

    task :symlink do
        transaction do
            run "ln -nfs #{current_release} #{deploy_to}/#{current_dir}"
            run "ln -nfs #{deploy_to}/#{current_dir} #{document_root}"
        end
    end

    task :migrate do
    end

    task :restart do
    end
end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埋葬我深情 2025-01-14 13:34:43
 role :db,  "<server's IP>", primary => true

应该是

 role :db,  "<server's IP>", :primary => true
 role :db,  "<server's IP>", primary => true

Should be

 role :db,  "<server's IP>", :primary => true
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文