Mkdir( '/var/www/html' ); permission denied

I’m running a build where I boot up a selenium server to do some acceptance testing. I boot up a few things, install WordPress into /var/www/html/ and run through my PHP script.

Inside of that script, I’m attempting to create a directory inside of /var/www/html/wp-content/uploads/ but it’s hitting permission denied error. I’ve tried literally everything I can think of to resolve this so my builds succeed, but I can’t get beyond this permission denied.

The entire /var/www/html directory is owned by circleci:circleci so there should be no permissions issue. I’ve tried chowning everything from /var down, setting permissions to 0755, but nothing. All of my other acceptance tests pass, but this one where mkdir() is executed will not pass.

If I SSH into the build to debug and then execute the following command from the command line there is no permission issue: php -r “mkdir( ‘/var/www/html/wp-content/uploads/test’ );”. I just don’t see what’s going on.

Acceptance tests run fine locally, and manual testing is perfectly fine, this only occurs in this build

The build is for a private repo, so it’s not publicly accessible.

May we see your config.yml? Normally apps are checked out into /app, so I am wondering how you get WP into the /var folder you’ve specified.


In my config ive pulled down the latest version of WordPress using wget and installed it into that directory manually.

In the end, after much hair pulling, the reason was that the directory wasn’t in fact owned by CircleCI because that’s the user executing the config.yml setup steps. But when it came time to test the plugin the www-data user was trying to create directories in the directories owned by the circleci user.

To work around this, just before kicking off the acceptance test I set ownership of those directories to www-data, so the Apache user would access the directories.

In the end it just came down to my lack of knowledge of build environments and networking skills.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.