<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <generator>Persumi - Level up your writing and blogging with AI</generator>
  <category label="Blog" scheme="http://persumi.com/u/fredwu/tech/e/blog" term="blog"/>
  <category label="Tech" scheme="http://persumi.com/u/fredwu/tech" term="tech"/>
  <link href="http://persumi.com/u/fredwu/tech/e/blog/t/deploy"/>
  <link href="http://persumi.com/u/fredwu/tech/e/blog/t/deploy/feed/rss"/>
  <link rel="self" href="http://persumi.com/u/fredwu/tech/e/blog/t/deploy/feed/atom"/>
  <author>
    <name>Fred Wu</name>
    <email>ifredwu@gmail.com</email>
    <uri>http://persumi.com/u/fredwu</uri>
  </author>
  <subtitle/>
  <id>http://persumi.com/u/fredwu/tech/e/blog/t/deploy</id>
  <title>Blog (deploy) - Fred Wu&apos;s Tech</title>
  <updated>2026-05-01T13:38:35.819132Z</updated>
  <entry>
    <content type="html">&lt;![CDATA[&lt;p&gt;
Don’t you just hate it when you get the following errors during a &lt;a href=&quot;http://www.capify.org/&quot;&gt;Capistrano&lt;/a&gt; deployment?&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;bundle: command not found
Could not find RubyGem bundler (&amp;gt;= 0) (Gem::LoadError)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
In fact, even if you don’t use &lt;a href=&quot;http://gembundler.com/&quot;&gt;bundler&lt;/a&gt;, you might still get errors like this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;rake: command not found
Could not find RubyGem rake (&amp;gt;= 0) (Gem::LoadError)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
It turns out this has something to do with the &lt;code class=&quot;inline&quot;&gt;$PATH&lt;/code&gt; and &lt;code class=&quot;inline&quot;&gt;$GEM_HOME&lt;/code&gt; variables.&lt;/p&gt;
&lt;p&gt;
So here’s the quick fix.&lt;/p&gt;
&lt;p&gt;
Log in to your deployment server, as a root user, add the following line to &lt;code class=&quot;inline&quot;&gt;/etc/ssh/sshd_config&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;PermitUserEnvironment yes&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Don’t forget to restart &lt;code class=&quot;inline&quot;&gt;ssh&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;/etc/init.d/ssh restart&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Now, log in as the deployment user, and create ’~/.ssh/environment’ with the following content:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;PATH=/usr/local/rvm/gems/ruby-1.9.2-p0/bin:/bin:/usr/local/rvm/rubies/ruby-1.9.2-p0/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GEM_HOME=/usr/local/rvm/gems/ruby-1.9.2-p0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
&lt;em&gt;* The above paths are for your reference only, obviously you need to work them out for your server environment. The only thing you need to make sure is that the &lt;code class=&quot;inline&quot;&gt;GEM_HOME&lt;/code&gt;’s path matches one from the &lt;code class=&quot;inline&quot;&gt;PATH&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;
Now, to verify this all work, you may use &lt;code class=&quot;inline&quot;&gt;cap shell&lt;/code&gt; to start a new shell session and try out your commands.&lt;/p&gt;
]]&gt;</content>
    <published>2010-09-16T05:59:00.000000Z</published>
    <category label="Blog" scheme="http://persumi.com/u/fredwu/tech/e/blog" term="blog"/>
    <category label="Tech" scheme="http://persumi.com/u/fredwu/tech" term="tech"/>
    <link href="http://persumi.com/u/fredwu/tech/e/blog/p/bundle-command-not-found-or-could-not-find-rubygem-bundler-0-during-capistrano-deployment-no-problems"/>
    <author>
      <name>Fred Wu</name>
      <email>ifredwu@gmail.com</email>
      <uri>http://persumi.com/u/fredwu</uri>
    </author>
    <id>http://persumi.com/u/fredwu/tech/e/blog/p/bundle-command-not-found-or-could-not-find-rubygem-bundler-0-during-capistrano-deployment-no-problems</id>
    <title>`bundle: command not found` or `Could not find RubyGem bundler (&gt;= 0)` During Capistrano Deployment? No Problems!</title>
    <updated>2010-09-16T05:59:00.000000Z</updated>
  </entry>
  <entry>
    <content type="html">&lt;![CDATA[&lt;p&gt;
The &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Rails&lt;/a&gt; deployment flow is really smooth thanks to the powerful (and easy to use) &lt;a href=&quot;http://www.capify.org/&quot;&gt;Capistrano&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Capistrano not only works with Rails and other Ruby code bases, but also code bases in any programming languages, such as &lt;a href=&quot;http://php.net/&quot;&gt;PHP&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;
Here is an overview of what I did to get one of our PHP production sites up and running with Capistrano.&lt;/p&gt;
&lt;p&gt;
If you don’t already have &lt;a href=&quot;http://www.ruby-lang.org/en/&quot;&gt;Ruby&lt;/a&gt; and &lt;a href=&quot;http://rubygems.org/&quot;&gt;Rubygems&lt;/a&gt; installed, install them!&lt;/p&gt;
&lt;p&gt;
After you got &lt;code class=&quot;inline&quot;&gt;ruby&lt;/code&gt; and &lt;code class=&quot;inline&quot;&gt;rubygems&lt;/code&gt;, install Capistrano and its related gems -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;gem install capistrano-ext railsless-deploy&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Now, navigate to your application’s directory and run &lt;code class=&quot;inline&quot;&gt;capify .&lt;/code&gt;, this will generate some necessary files for Capistrano to recognise your app.&lt;/p&gt;
&lt;p&gt;
Open up the generated &lt;code class=&quot;inline&quot;&gt;Capfile&lt;/code&gt; file and replace the content of the file with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby language-ruby&quot;&gt;require &apos;rubygems&apos;
require &apos;railsless-deploy&apos;
load &apos;config/deploy&apos;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Okay, now we need to set up the actual deployment recipe in the &lt;code class=&quot;inline&quot;&gt;config/deploy.rb&lt;/code&gt; file. But before doing so, we need to set up our deployment server with proper user and deployment permission.&lt;/p&gt;
&lt;p&gt;
We chose to set up a new user called &lt;code class=&quot;inline&quot;&gt;deploy&lt;/code&gt; specifically for deployment purpose, for example -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;useradd deploy&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Then of course, we need the SSH keys for this deployment user, so switch to this user (&lt;code class=&quot;inline&quot;&gt;su deploy&lt;/code&gt;) and -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;ssh-keygen&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
We use &lt;a href=&quot;http://github.com/&quot;&gt;GitHub&lt;/a&gt;, so simply copy the content of the public key (&lt;code class=&quot;inline&quot;&gt;~/.ssh/id_rsa.pub&lt;/code&gt;) and add it to the deploy keys section of the Github repository.&lt;/p&gt;
&lt;p&gt;
Don’t forget to also add GitHub to the &lt;code class=&quot;inline&quot;&gt;.ssh/known_hosts&lt;/code&gt; file, you can do this by manually cloning your repository on the deployment server.&lt;/p&gt;
&lt;p&gt;
Great! Now let’s do the last step - create the actual deployment recipe!&lt;/p&gt;
&lt;p&gt;
Open up &lt;code class=&quot;inline&quot;&gt;config/deploy.rb&lt;/code&gt; file and you will see some default deployment tasks. Everyone has different needs, so I’m going to paste our &lt;code class=&quot;inline&quot;&gt;deploy.rb&lt;/code&gt; file (masked with added comments) for your reference.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby language-ruby&quot;&gt;set :user, &quot;deploy&quot;
set :application, &quot;YOUR_APPLICATION_NAME&quot;
set :domain, &quot;YOUR_APPLICATION_DOMAIN_NAME&quot;
set :repository, &quot;THE_ADDRESS_OF_THE_APPLICATION_REPOSITORY&quot;
set :deploy_to, &quot;/var/www/#{domain}&quot;
set :shared_path, &quot;#{deploy_to}/shared&quot;
set :use_sudo, false

set :scm, :git
set :branch, &apos;master&apos;
set :deploy_via, :remote_cache

role :web, &quot;ADDRESS_OF_YOUR_WEB_SERVER&quot;
role :app, &quot;ADDRESS_OF_YOUR_APP_SERVER&quot; # this can be the same as the web server
role :db, &quot;ADDRESS_OF_YOUR_DB_SERVER&quot;, :primary =&gt; true # this can be the same as the web server

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
  run &quot;#{try_sudo} /etc/init.d/lsws reload&quot; # we use LiteSpeed Web Server
  end
end

# The task below serves the purpose of creating symlinks for asset files.
# Large asset files like user uploaded contents and images should not be checked into the repository anyway, so you should move them to a shared location.

task :create_symlinks, :roles =&gt; :web do
  run &quot;ln -s #{shared_path}/uploads #{current_release}/uploads&quot;
  run &quot;ln -s #{shared_path}/zb #{current_release}/zb&quot;
end

# Let&apos;s run the task immediately after the deployment is finalised.

after &quot;deploy:finalize_update&quot;, :create_symlinks&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
That’s it! Now you should be able to deploy your application by -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;cap deploy:setup
cap deploy&lt;/code&gt;&lt;/pre&gt;
]]&gt;</content>
    <published>2010-06-21T04:45:00.000000Z</published>
    <category label="Blog" scheme="http://persumi.com/u/fredwu/tech/e/blog" term="blog"/>
    <category label="Tech" scheme="http://persumi.com/u/fredwu/tech" term="tech"/>
    <link href="http://persumi.com/u/fredwu/tech/e/blog/p/deploy-php-websites-using-capistrano-and-git"/>
    <author>
      <name>Fred Wu</name>
      <email>ifredwu@gmail.com</email>
      <uri>http://persumi.com/u/fredwu</uri>
    </author>
    <id>http://persumi.com/u/fredwu/tech/e/blog/p/deploy-php-websites-using-capistrano-and-git</id>
    <title>Deploy PHP Websites Using Capistrano (and Git)</title>
    <updated>2010-06-21T04:45:00.000000Z</updated>
  </entry>
</feed>