Roots Discourse

Having difficulty deploying bedrock

So, I have a project completed. I’m trying to deploy it (avoiding Trellis on this first go as Ansible is a touch complicated for me I just want to understand the basics of how to do this first and then Trellis next go).

I spun up a digitalocean droplet, LEMP stack.

Got an ssl cert with certbot. So far so good, everything works hello world from /var/www/html.

Cloned my bedrock project and put it in /srv/www/

Created a wordpress database user, new database, and put all this in the .env.

Configured the nginx conf to match

sudo systemctl reload nginx (also tried restarting and even rebooting)

Now I expected to see a default twentytwentyone theme at, but instead in Chrome a download is forced name ‘download’ and the contents are the exact contents of web/index.php.

So, its using the new directory on /srv/www/, but something is not firing right.

Is it possibly the nginx conf still? I copied the contents of the above mentioned docs into /etc/nginx/sites-available/digitalocean, but there are plenty of other files in there too. Would it be helpful if I started from a default Ubuntu droplet and just manually installed php, mariadb, nginx etc. instead of using the defaul digitalocean droplet?

I’m kinda stumped about the ‘download’ behavior. Anyone knows what that means?

This is probably not the best place to get help for webserver configuration, but you’ll at least need to provide some snippets from your conf in order to troubleshoot better

Turns out it wasn’t my nginx config, but missing dependencies with PHP. I took a look at all the PHP dependencies in the Trellis repo and just made sure to install all of those, and it works now as expected. I knew I was overlooking something basic. Thanks for your time.

Edit: So, now bedrock is working and the default twentytwentyone theme works fine, but when I switch to my sage theme I get a white screen. It must be more dependencies or some other basic step I’m missing again. Will update if I’m able to figure it out. If anything comes to mind, I’d appreciate any suggestions.

The Sage theme itself also needs a PHP runtime that is managed using composer. You may have to run composer install. Also check the PHP logs as PHP notices/warnings/errors should/are disabled in production environments, hence the white screen.

1 Like

I’ve run composer install in bedrock and composer install, yarn, and yarn build:production in the sage directory. The nginx error log is telling me it can’t find /var/www/, but yet it is indeed there. I’ve the ownership set to $user:$user.

The site was working perfectly fine with static html files before I installed bedrock though. I also tested some basic php function and tested accessing an example mysql database. Everything worked fine. Then, as I mentioned, the default bedrock install seemed to work, but switching to the sage theme gives me white screen.

If I set WP_DEBUG_DISPLAY to true in the .env will it override that I’m in staging/production? When you say check the php logs, do you mean the file that is set in the .env, WP_DEBUG_LOG? Is that what you’re suggesting?

I wasn’t sure how to get it into debug mode for staging/production, so I set it to development to find out what is going on…

"The stream or file "/var/www/" could not be opened in append mode: failed to open stream: Permission denied

Are you aware of the correct ownership of the contents of /var/www/ I did a chown -R $user:$user /var/www/ so I could clone my git repo easily. I’m pretty unsure but I think it might need to be www-data:www-data, but really need to do a lot of reading before I’m sure (there is plenty of conflicting information out there). It could be actual file permissions too, but my rough guess it is an ownership issue.

Looking at Trellis, I think its web:www-data, whereas ‘web’ could be any normal user in the www-data group. Does that sound right?

EDIT: It was indeed the file ownership. When I chown -R www-data:www-data /var/www/ there is no more white screen and the site works as expected. Now, I’m not sure if this is best practice, but it does work for now. I might create a non-sudo user call it ‘web’ just as Trellis does.

1 Like

As you are not using Trellis, you have to ensure by other means that the ownerships/permissions are correct.
According to a Trellis setup, the storage/ directory should be owned by the web user and the www-data group, and its permissions should be 755 (drwxr-xr-x).
In fact, all folders below app/ should have these attributes.

Oh shucks. I must have missed that! Thanks for pointing that out. I think I learned pretty clearly these last few days its MUCH easier to just use Trellis. I ended up manually re-creating everything that Trellis would have done anyway. In the end, I got it working and its a good learning experience but not sustainable for the long run. Bottom line: use Trellis.

This topic was automatically closed after 42 days. New replies are no longer allowed.