I
I
Igor Koch2017-03-25 14:18:57
CMS
Igor Koch, 2017-03-25 14:18:57

How to set up LEMP (Nginx & php7 & mySql) on Ubuntu 16.04?

Installed on a clean LEMP server following the instructions:
https://www.digitalocean.com/community/tutorials/l...
Transferred from sepverpilot ( Another server ) Kirby CMS
files pg.site.com <- Here's what happened, all my attempts configure NGINX were unsuccessful.
Now I have these settings:

server {
    listen 80;
    listen [::]:80;

    root /var/www/pg.site.com/public;
    index index.php index.html index.htm;

    server_name pg.site.com www.pg.site.com;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        # include snippets/fastcgi-php.conf;
        # fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}

Can you please explain how to set it up?
Upd:
I decided everything in the end like this:
I configured nginx for Kirby
server {
    listen 80;
    listen [::]:80;

    root /var/www/pg.whata.ninja/public;
    index index.php index.html index.htm;

    server_name pg.site.com www.pg.site.com;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    #location / {
    #    try_files $uri $uri/ =404;
    #}

    location ~ /\.ht {
        deny all;
    }

   	##############################
    ## Kirby configuration
    ##############################

    # Don't hint these as folders
    rewrite ^/(content|site|kirby)$ /error last;

    # block content
    rewrite ^/content/(.*).(txt|md|mdown)$ /error last;

    # block all files in the site and kirby folder from being accessed directly
    rewrite ^/(site|kirby)/(.*)$ /error last;

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename) {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # panel links
    location ~ /panel {
        try_files $uri $uri/ /panel/index.php?$uri&$args;
    }

    # site links
    location ~ / {
        try_files $uri $uri/ /index.php?$uri&$args;
    }

    # Prevent clients from accessing hidden files (starting with a dot)
    # This is particularly important if you store .htpasswd files in the site hierarchy
    location ~ (?:^|/)\. {
        deny all;
    }

    # Prevent clients from accessing to backup/config/source files
    location ~ (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
        deny all;
    }

    ##############################
    ## End Kirby CMS configuration
    ##############################
}

In php.ini I registered
short_open_tag = On
And installed php7.0-mbstring

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergej, 2017-03-25
@amux

1) What a person from the IT sphere always does - reads logs. /var/log/nginx/error.log
2) Looks at them and finds out the reason
...
And also compares the config from the given docks with his own. And if he does not have -100 vision, then he sees something superfluous.
And why does he write the tags <? instead of <?php.
Although if he allowed the writing of short tags, then ok.

S
SimBioT19, 2017-03-25
@SimBioT19

sudo apt-get update

sudo apt-get upgrade

sudo apt-get dist-upgrade


sudo apt-get install python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get install nginx

sudo apt-get install php

sudo apt install mysql-server mysql-client

sudo apt-get install phpmyadmin php-mbstring php-gettext

sudo apt-get install php7.0-sqlite
sudo phpenmod mcrypt mbstring

sudo apt-get install php-curl cron

sudo mkdir /etc/nginx/sites-available && sudo mkdir /etc/nginx/sites-enabled

Further setup of nginx configs. Maybe I'll write mine tonight if needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question