Mkdir: cannot create directory `/var/www': Permission denied

Still fiddling with bedrock-capistrano on shared hosting and getting mkdir: cannot create directory /var/www’: Permission denied` error.

Is it on the server that Capistrano is trying to write to /var/www? Because that is owned by Root (of course). Is there a workaround? Am I misunderstanding something?

Capistrano only creates the directory you have set in deploy_to. See

So yes it would try to create /srv/ww/<app_name> by default on the server. Or maybe /var/www in your case. Obviously whatever directory you set for deploy_to needs to have permissions set up for Capistrano’s user to create/edit files/directories in there.

Ah, thank you! Should that directory be pointed above the public_html dir?

Yes. We probably do want it above the public_html dir. I have set to /home/user/deploy.

Seems to be looking in the default directory for Capistrano, even though I have set a different path in config/deploy/production.rb:

# Let's put composer.phar location in our path set :default_env, { path: "/home/account_name/bin:$PATH" }

Output is:

Command: cd /home/account_name/deploy/releases/20150825034929 && ( PATH=/home/hamiltonwellness/bin:$PATH /usr/bin/env composer install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )

You can always just do:

SSHKit.command_map[:composer] = '/path/to/composer.phar'.

See Deploying WordPress with Capistrano screencast

Great! Getting there. Still getting exit status > 0, though:

DEBUG[00ac408b]     stdin: is not a tty
cap aborted! 
SSHKit::Runner::ExecuteError: Exception while executing on host account_name: composer exit status: 2
composer stdout: Nothing written ```

If I `cd ` into the latest release directory and run `/home/account_name/bin/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader` there's no output whatsoever.

Contents of release/TIMESTAMP directory is:

./            composer.json    deploy.rb     .gitignore     REVISION     vendor/
../           composer.lock    .env.example     ruleset.xml  web/
Capfile       config/          Gemfile       production.rb  staging.rb   wp-cli.yml  Gemfile.lock      .travis.yml

Wait a minute! Let’s try running composer install without all the flags, in particular the --quiet flag.

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - This package requires php >=5.4 but your PHP version (5.3.29) does not satisfy that requirement. 

Update php version via CPANEL and we seem to be in business.

Finished in 0.138 seconds with exit status 0 (successful).

Getting 500 Server Error on front end now.

I’m trying to use combination of .htaccess and symlinks where .htaccess redirects to web

RewriteEngine on
RewriteRule ^(.*)$ /web/$1
Require all granted

And web is a symlink that points to ..deploy/current/web where ../deploy/current is also a symlink pointing to the latest release in /home/hamiltonwellness/deploy/releases/TIMESTAMP/

The symlinks are all owned by account_name, with permissions of 777 (the default?).

changed access bits set on the folder /home/hamiltonwellness/deploy/ from 777 to 755

updated htaccess:

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^(www.)?$ 
RewriteCond %{REQUEST_URI} !^/web/ 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /web/$1 
RewriteCond %{HTTP_HOST} ^(www.)?$ 
RewriteRule ^(/)?$ web/index.php [L]