Forcing https with wordpress on dreamhost

In order to be able to force the http to https redirection when using wordpress in dreamhost use the following (taken from https://help.dreamhost.com/hc/en-us/articles/215747758-Force-your-site-to-load-securely-with-an-htaccess-file) :

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"

# BEGIN WordPress
.....
# END WordPress

Dreamhost, DreamCompute(OpenStack) ssh login

Problem

You have just created your first instance in Dreamhost’s new service DreamCompute using OpenStack and you would like to login with ssh, but you get ‘Permission Denied’.

Solution

The solution is described here, and it’s the fact that the user name that you need to use is not your Dreamhost account name, or the DreamCompute dashboard user anme but the the username called:

dhc-user

NOTE: It seems that is also described here, at the bottom.

Dreamhost keeps asking for password when installing rvm ruby version

Problem

After installing rvm on dreamhost, when trying to install any ruby version afterwards, there is a prompt for password, and when entering the user’s password there is the message that the user is not in the sudoers list.

Solution

To be able to install the rvm ruby version you would like you should be installing them by using the following which is based on the answer here :

rvm list remote
ruby-1.9.3-p194
   ruby-1.9.3-p286
   ruby-1.9.3-p327
   ruby-1.9.3-p362
   ruby-1.9.3-p374
   ruby-1.9.3-p392
   ruby-1.9.3-p429
   ruby-1.9.3-p448
   ruby-2.0.0-p0
   ruby-2.0.0-p195
   ruby-2.0.0-p247

and then:

rvm mount -r https://rvm.io/binaries/debian/6/x86_64/ruby-2.0.0-p247.tar.bz2 --verify-downloads 1

fatal: cannot exec ‘/tmp/…/git-ssh.sh’: Permission denied – Capistrano, Dreamhost, permission denied for git-ssh.sh

Problem

When trying to use the new Capistrano 3.x to set up your rails project in a dreamhost account, you get the following error complaining that the git-ssh.sh script copied to your account by capistrano cannot be executed as the permission is denied:

fatal: cannot exec '/tmp/example.com/git-ssh.sh': Permission denied

Solution

It seems that Dreamhost, and quite possibly other hosting providers are not allowing executables from the /tmp directory, which is where Capistrano places the git-ssh.sh script. So in order to be able to execute the script you can change the directory where the script is copied in the first place and put it in your home directory. You can do that by adding the following to the config/deploy.rb file:

set :tmp_dir, "/home/dh_user_name/tmp"

Internal 500 server error – Dreamhost – Rails 3.0.3 – Capistrano

Problem
You want to deploy your Rails 3.0.3 in Dreamhost with capistrano, but even though you follow the steps from a previous post here, when you go to the application’s main page you still get an error:

500 Internal Server Error

Solution
Thanks to a blog post from Brendon Wilson here, the last missing piece from the puzzle in order to have your application running is to add the following line to the top of your deploy.rb file:

require 'bundler/capistrano'

and redo your cap deploy.

Thanks Brendon.

Rails 3 – Bundler – Dreamhost – Capistrano

Problem
You want to deploy your Rails (3.0.3) application to Dreamhost using Capistrano, but you get errors like:

bundle command not found
or
Enter your password to install the bundled RubyGems to your system:

Solution
You may be able to see in your deploy.rb file a commented section that says the following:

As Capistrano executes in a non-interactive mode and therefore doesn’t cause
any of your shell profile scripts to be run ….

So in order for capistrano to be able to find your bundle command you should add in your deploy.rb file a line with your paths (ie):

default_environment['PATH']='/usr/lib/ruby/gems/1.8/bin:/home/your_name/.gems/bin:/usr/local/bin:/usr/bin:/bin'

If you have the previous line your bundle command can run, but if you try to do cap:deploy your bundler will probably give you an error as it would ask for your sudo password. In order to avoid this error and to make it work you have to add another line with your gem path (ie):

default_environment['GEM_PATH']='/home/your_name/.gems:/usr/lib/ruby/gems/1.8'

making sure that your home directory path for your gems is first in the list.

capistrano deployment fails after dreamhost server move

Problem
You have set up your capistrano recipe for deployment to dreamhost using password less logins, but after dreamhost moves your git repository server to a different server, the deployment breaks, with ‘permission denied’ when trying to get the git repository.

Solution
As the server was moved you would need to copy your ssh public key from the deployment server to the new server again for the password-less logins to work again.
Follow the details here how to copy your public key across, login in once with your password, and after that your capistrano recipe should be working again as normal.

git and dreamhost : refusing to update checked out branch: refs/heads/master

Problem
After dreamhost decided to move my account that hosted the git repository to a new server, first time I’ve tried to push some changes to the git repository I was faced with the followng error:

Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 699 bytes, done.
Total 7 (delta 6), reused 0 (delta 0)
error: refusing to update checked out branch: refs/heads/master
error: By default, updating the current branch in a non-bare repository
error: is denied, because it will make the index and work tree inconsistent
error: with what you pushed, and will require 'git reset --hard' to match
error: the work tree to HEAD.
error:
error: You can set 'receive.denyCurrentBranch' configuration variable to
error: 'ignore' or 'warn' in the remote repository to allow pushing into
error: its current branch; however, this is not recommended unless you
error: arranged to update its work tree to match what you pushed in some
error: other way.
error:
error: To squelch this message and still keep the default behaviour, set
error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://dh_user@dh_domain/home/repository_path/projects/project.git

Solution
After searching and finding out various solutions to solve the problem, none of which was specific to a server move, I’ve tried the following:

  • Followed the steps here to set up a new repository project_asm.git
  • went to local project changed the config file to add the new remote repository
  • issued git push new_remote master
  • make a code change and then git push

And everything should work as normal again.

Deploying a Rails project in a server that hosts the git repository

Problem
You want to deploy your project in a server (dreamhost), that also hosts your git repository. When you try to do that by only setting the set_repository, you get errors like ‘permission denied, please try again’, even though if you try to checkout the git repository on your server works.

Solution
Set your :repository as a file in your host as in:
set :repository, "file:///home/username/git_on_server/projects/repo_name.git"

Then also set up your local_repository, as in:
set :local_repository, "user_name@server_domain_name:/home/username/git_on_server/projects/repo_name.git"