Roots Discourse

Nginx, Bedrock and 404 when installing with nginx


#1

I seem to be having an issue when trying to setup bedrock with nginx. I’ve managed to get my server configuration working with just a normal WordPress install so I’m 90% sure it’s not that but just incase I have added the necessary code below.

Basically when I go into the subdirectory where bedrock is installed it will redirect me to wp/wp-admin/install.php but then it just returns a 404.

/etc/nginx/sites-enabled/example.co.uk.conf

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name example.co.uk;
    set $base /var/www/example.co.uk;
    root $base;

    # SSL
    ssl_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.co.uk/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;

    # index.php
    index index.php;

    # index.php fallback
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /site1 {
	root $base/site1;
	try_files $uri $uri/ /site1/web/index.php?$query_string;
	autoindex on;
    }

    # handle .php
    location ~ \.php$ {
        include nginxconfig.io/php_fastcgi.conf;
    }

    include nginxconfig.io/general.conf;
}

# subdomains redirect
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name *.example.co.uk;

    # SSL
    ssl_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.co.uk/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.co.uk/fullchain.pem;

    return 301 https://example.co.uk$request_uri;
}

# HTTP redirect
server {
    listen 80;
    listen [::]:80;

    server_name .example.co.uk;

    include nginxconfig.io/letsencrypt.conf;

    location / {
        return 301 https://example.co.uk$request_uri;
    }
}

/etc/nginx/nginxconfig.io/php_fastcgi.conf

try_files $uri =404;

# fastcgi
fastcgi_pass                unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index                index.php;
fastcgi_split_path_info        ^(.+\.php)(/.+)$;
fastcgi_param                SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param                PHP_ADMIN_VALUE open_basedir=$base/:/usr/lib/php/:/tmp/;
fastcgi_intercept_errors    off;

fastcgi_buffer_size                128k;
fastcgi_buffers                    256 16k;
fastcgi_busy_buffers_size        256k;
fastcgi_temp_file_write_size    256k;

# default fastcgi_params
include fastcgi_params;

Like I said when I land on https://example.co.uk/site1 it will redirect me to https://example.co.uk/site1/wp/wp-admin/install.php where the WordPress install begin but this page is just a 404

If there is anything else I need to provide to help let me know been stuck on this error for around 3 hours now and nothing on Google has helped. Also there is no error in the nginx logs