Ansible Provisioning Issue - Solved

I’m trying to provision a staging server with Ansible (as I’ve done many times before).

I cloned the Trellis repo and then created a new $5 DO instance, locked it down, configured the staging hosts and group_vars files and ran:

ansible-playbook -i hosts/staging server.yml --ask-sudo-pass

The process completed successfully.

I then deployed the Bedrock/Sage project with:

./deploy.sh staging site.net

The deploy ran successfully.

When I go to the staging site in the browser, I get the white screen of death.

I can see the incoming requests in the Nginx access log, and there are no errors in the Nginx error log.

I checked that php5-fpm and MySQL are both running. I checked that I see a 404 if I put in a dummy page request.

I restarted the the VM.

I even destroyed the VM, created a new one and ran through it all again with the same result.

I’ve checked that all of the env settings are correct.

For some reason Nginx is not serving WordPress as expected and I can’t figure it out.

Am I missing something obvious?

Does the WP admin work?

Check the sites logs? White screen means an early PHP error so it wouldn’t be nginx

This happens to me all the time, its the weak link in the whole Trellis process because I don’t know why! Its my fault for not fully understanding how nginx works, but its really frustrating.

When you destroyed the VM, did you also remove the .vagrant folder in the project root? I don’t know if that makes a difference, but it might.

Thanks for the replies

No, I get the white screen for any WordPress URL I try. I get the Nginx 404 if I try to access a non existent page.

There are no errors in the site logs under /srv/www/site.net/logs/

I just checked the php5-fpm.log under /var/log and that just has:

[08-Jul-2015 22:45:14] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful

I’m going to run through the process again with a fresh copy of trellis and see how I get on. I must have overlooked something. Thanks…

So I ran through the process again, fresh DO droplet, fresh clone of Trellis, same result.

After almost tearing my non-existent hair out, I decided to roll up my sleeves and do some serious debugging.

Turns out @kalenjohnson was right - it was a PHP error, and an interesting one.

After setting display_errors = On in php.ini, I got this:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Dotenv values containing spaces must be surrounded by quotes.' in /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Loader.php:234 Stack trace: #0 /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Loader.php(104): Dotenv\Loader->sanitiseVariableValue('LOGGED_IN_KEY', 'c>W:Wb/:Fwew(<t...') #1 /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Loader.php(336): Dotenv\Loader->normaliseEnvironmentVariable('LOGGED_IN_KEY=c...', NULL) #2 /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Loader.php(60): Dotenv\Loader->setEnvironmentVariable('LOGGED_IN_KEY=c...') #3 /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Dotenv.php(40): Dotenv\Loader->load() #4 /srv/www/site.net/releases/20150709034342/config/application.php(10): Dotenv\Dotenv->load() #5 /srv/www/site.net/releases/20150709034342/web/wp-config.php(8): require_once('/srv/www in /srv/www/site.net/releases/20150709034342/vendor/vlucas/phpdotenv/src/Loader.php on line 234

I think this is probably why others including @evanfuture are seeing the white screen of death - you have to make sure there are no spaces in your generated salts!

Case closed.

3 Likes

Oooooh, I had this the other day also. Replaced the two spaces I had with another character.

The strange thing is, generating the .env file, at least the template, hasn’t changed since Trellis was released: https://github.com/roots/trellis/blob/master/roles/wordpress-install/templates/env.j2

So either something happened recently with the PHP dotenv, or spaces have been added to the WP generated salts. Or it’s just been overlooked or hasn’t happened enough to be noticed. Not sure…

I wonder if we should add quotes to the generated .env file. Would have to test it though.

2 Likes

Dotenv was updated recently: https://github.com/roots/bedrock/pull/190

Thanks for this debugging @treb0r. I’ll update the env template in Trellis.

Done: https://github.com/roots/trellis/blob/8679312194dca96b3271fc1a1a886989e6bdde26/roles/wordpress-install/templates/env.j2

Want to try this out?

Tried it out, still getting the error:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Dotenv values containing spaces must be surrounded by quotes.' in /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Loader.php:234 Stack trace: #0 /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Loader.php(104): Dotenv\Loader->sanitiseVariableValue('LOGGED_IN_KEY', 'c>W:Wb/:Fwew(<t...') #1 /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Loader.php(336): Dotenv\Loader->normaliseEnvironmentVariable('LOGGED_IN_KEY=c...', NULL) #2 /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Loader.php(60): Dotenv\Loader->setEnvironmentVariable('LOGGED_IN_KEY=c...') #3 /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Dotenv.php(40): Dotenv\Loader->load() #4 /srv/www/site.net/releases/20150709085825/config/application.php(10): Dotenv\Dotenv->load() #5 /srv/www/site.net/releases/20150709085825/web/wp-config.php(8): require_once('/srv/www in /srv/www/site.net/releases/20150709085825/vendor/vlucas/phpdotenv/src/Loader.php on line 234

In my case (I algo got this blank screen) the salt keys were generating big troubles. After removing them (which is not the best permanent solution) the site went back again.

Did you verify by looking in the generated .env file that the quotes were really there?

Just checked and they’re not there.

I have also checked git and I am up to date.

I can see your commit when I run git log in the ansible directory, but looking at the .env template, it’s not changed. I’ll try a fresh clone.

It’s not working, but I realised I was looking at a different template

/roles/deploy/templates/env.j2

I can see your change to

/wordpress-install/templates/env.j2

1 Like

Oh always forget there’s two. Just updated the other. Thanks!

2 Likes

All working now, thanks @swalkinshaw :smile: