New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

My ngin(x) won't start.

mar627 February 18, 2019 by mar627
  • ubuntu 18.04
  • php7.2-fpm
  • nginx/1.14.0

Using the Statamic supplied .conf file, I've done four things to make it mine, yet my site remains blank:

  1. added my domains -- line 3
  2. specified the root folder -- line 4
  3. commented out line 43 and uncommented 44
  4. change 7.0 to 7.2 -- line 44

.

Here it is in its entirety: /etc/nginx/sites-available/mysite

server {
    listen 80;
    server_name my-site.com www.my-site.com;
    root /var/www/html/statamic;

    ssl_protocols TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    # Dynamically set the try_files locations.
    # Statically cached files should only be loaded for GET requests.
    set $try_files @default;
    if ($request_method = GET) {
        set $try_files @static;
    }

    # The files to try when its a potentially static cache request (ie. a GET request)
    location @static {
        try_files /static${uri}_${query_string}.html @default;
    }

    # The files to try when it's not a static cache request (ie. anything other than GET)
    location @default {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location / {
        try_files $uri $try_files; # Use the dynamically assigned locations from above.
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/example.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        # fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    # Block access to hidden files (except the /.well-known/ dir)
    location ~ /(?!.well-known)(\.)\w+ {
        deny all;
    }

    # Block access to content/data files
    location ~* /(.*)\.(?:md|yaml|textile)$ {
        deny all;
        return 404;
    }

    # Block access to the Statamic app
    location ^~ /statamic {
        deny all;
        return 404;
    }

    # Enable gzip compression
    # gzip on;
    # gzip_min_length  1100;
    # gzip_buffers  4 32k;
    # gzip_types    text/plain application/x-javascript text/xml text/css;
    # gzip_vary on;
}

.

What am I missing, my site is blank! (zilch - just white).

UPDATE: When I use the below .conf my site works. There are subpages, images are rendering and I can access the cp. WHY? There must be something else I need to change in the Statamic supplied .conf above.. I know I can just use the below one but its missing all the Statamic set goodies, and it'd be nice to know where I went wrong.

Thank you ✨

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/statamic;
    index  index.php index.html index.htm;
    server_name  my-site.com www.my-site.com;

     client_max_body_size 100M;

     autoindex off;

     location / {
        rewrite ^/admin.php.*$ /admin.php;
        try_files $uri $uri/ /index.php?$query_string;
      }

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
    }
}
Answered by mar627!
>>>>>>> Answered <<<<<<<
4 Replies
2 Followers