Error on deploy at task WordPress Installed?

When deploying a fresh (ssl) site to production server, I receive a PHP notice and an error establishing a database. Not sure if I made a mistake somewhere or if it’s a bug.
I’m on the latest Trellis and Bedrock.

TASK [deploy : WordPress Installed?] *******************************************
System info:
  Ansible 2.2.0.0; Linux
  Trellis at "Add myhostname to nsswitch.conf to ensure resolvable hostname"
---------------------------------------------------
 PHP Notice:  Constant DISALLOW_FILE_EDIT already defined in /srv/www/mysite
    .nl/releases/20161121125004/config/application.php on line 76
    Error: Error establishing a database connection. This either means that the
    username and password information in your `wp-config.php` file is incorrect
    or we can’t contact the database server at `localhost`. This could mean your
    host’s database server is down.
    fatal: [my.ip.address]: FAILED! => {"changed": false, "cmd": ["wp", "core",
    "is-installed"], "delta": "0:00:00.180013", "end": "2016-11-21 12:50:23.097210",
    "failed": true, "failed_when_result": true, "rc": 1, "start": "2016-11-21
    12:50:22.917197", "stderr": "PHP Notice:  Constant DISALLOW_FILE_EDIT
    already defined in /srv/www/mysite.nl/releases/20161121125004/config/application.php
    on line 76\nError: Error establishing a database connection. This either
    means that the username and password information in your `wp-config.php` file
    is incorrect or we can’t contact the database server at `localhost`. This could
    mean your host’s database server is down.", "stdout": "", "stdout_lines":
    [], "warnings": []}

wordpress_sites.yml:

mysite.nl:
  site_hosts:
    - canonical: mysite.nl
      redirects:
        - www.mysite.nl
  local_path: ../sites/mysite.nl # path targeting local Bedrock site directory (relative to Ansible root)
  repo: git@gitlab.path # replace with your Git repo URL
  # repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
  branch: master
  multisite:
    enabled: false
  ssl:
    enabled: true
    provider: letsencrypt
  cache:
    enabled: true
  env:
    wp_home: https://mysite.nl
    wp_siteurl: https://mysite.nl/wp

Did you check to see if the database and database user were created properly?

A wp-cli db check gives me an access denied:

PHP Notice:  Constant DISALLOW_FILE_EDIT already defined in /srv/www/mysite.nl/releases/20161121125004/config/application.php on line 76
mysqlcheck: Got error: 1045: Access denied for user 'mysite_nl'@'localhost' (using password: YES) when trying to connect

Would that mean the db and db user weren’t created during provision (no errors on provision though), or some sort of permission error?

That’s more what I was asking. You can go into your mysql console with the root user and see what databases and users exist.

I’ve checked the mysql console. Both database and user appear to have been created.

Next thing you can verify is the .env file that Trellis generates in your web root. It should contain the proper database name and credentials that you can also try to manually connect to MySQL with.

Yes, I can also log into the mysql console with the db credentials from the .env file.

I’ve used a pw generator for a long db password and I notice that it contains characters like ’ and ` could it be that Trellis don’t like these?

Trellis wraps them in double quotes in various places so it should be fine in Trellis/Ansible. Maybe PHP/WP is having a problem with them.

But if the .env file exists and those credentials work… then it’s looking like an issue after that. Meaning once PHP reads it and WP executes.

Changing the password to one without special characters fixed the database error.
Provision still fails with the PHP Notice: Constant DISALLOW_FILE_EDIT already defined error, unless I comment out line 76 in application.php.

1 Like

I’d do a grep -r DISALLOW_FILE_EDIT . in your codebase to see if that constant is defined in two places.