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

**URL:** https://discourse.roots.io/t/mkdir-cannot-create-directory-var-www-permission-denied/4564
**Category:** bedrock
**Tags:** deploys
**Created:** 2015-08-25T03:26:47Z
**Posts:** 11

## Post 1 by @mZoo — 2015-08-25T03:26:47Z

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?

---

## Post 2 by @swalkinshaw — 2015-08-25T03:29:48Z

Capistrano only creates the directory you have set in `deploy_to`. See [https://github.com/roots/bedrock-capistrano/blob/01a2657dfb5cbe158a8640cf26f65a5f956da20e/config/deploy.rb#L12](https://github.com/roots/bedrock-capistrano/blob/01a2657dfb5cbe158a8640cf26f65a5f956da20e/config/deploy.rb#L12)

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.

---

## Post 3 by @mZoo — 2015-08-25T03:35:07Z

Ah, thank you! Should that directory be pointed _above_ the public\_html dir?

---

## Post 4 by @mZoo — 2015-08-25T03:41:49Z

Yes. We probably do want it above the public\_html dir. I have set to `/home/user/deploy`.

---

## Post 5 by @mZoo — 2015-08-25T03:59:30Z

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 )`

---

## Post 6 by @swalkinshaw — 2015-08-25T04:03:08Z

You can always just do:

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

See [Deploying WordPress with Capistrano screencast](https://discourse.roots.io/t/deploying-wordpress-with-capistrano-screencast/863/26?u=swalkinshaw)

---

## Post 7 by @mZoo — 2015-08-25T04:19:51Z

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.
```

---

## Post 8 by @mZoo — 2015-08-25T04:41:01Z

Contents of `release/TIMESTAMP` directory is:

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

---

## Post 9 by @mZoo — 2015-08-25T04:59:53Z

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).`

---

## Post 10 by @mZoo — 2015-08-25T05:22:36Z

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?).

---

## Post 11 by @mZoo — 2015-08-25T13:20:41Z

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

updated htaccess:

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