marcov4lente
3/8/2017 - 12:29 PM

LEMP Server Set Up

LEMP Server Set Up

NginX Setup

###Move to site available directory

$ cd /etc/nginx/sites-available

Create new site

$ sudo nano mynewsite.com

Add site config, and save

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

    root /var/www/marcov4lente.com;
    index index.php index.html index.htm index.nginx-debian.html;
    server_name marcov4lente.com;

    # enable rewrite
    location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    # deny access to .htaccess files
    location ~ /\.ht {
            deny all;
    }

Enable site

By symlinking it's configuration file to the sites-enabled folder:

ls -s /etc/nginx/sites-available/mynewsite.com /etc/nginx/sites-enabled/mynewsite.com

test nginx changes

$ nginx -t

Restart nginx-php

$ systemctl restart php7.0-fpm

Restart nginx-php

$ systemctl restart php7.0-fpm

restart nginx

$ systemctl reload nginx

update / upgrade

$ sudo apt-get update
$ sudo apt-get -y upgrade

Install nginx

$ sudo apt-get install -y nginx

enable UFW access if UFA is active

$ ufw allow 'Nginx HTTP'

Install mysql server

$ apt-get install -y mysql-server

Install PHP 7.0

$ sudo apt-get install -y php7.0
$ sudo apt-get install -y php-fpm
$ sudo apt-get install -y php-mysql
$ sudo apt-get install -y php-mbstring 
$ sudo apt-get install -y php-gettext
$ sudo apt-get install -y php-xml
$ sudo apt-get install -y php-curl

Configure PHP

$ nano /etc/php/7.0/fpm/php.ini

Set:

cgi.fix_pathinfo = 0

Restart nginx-php

$ systemctl restart php7.0-fpm

restart nginx

$ systemctl reload nginx

install git

$ apt-get install git

install composer

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

install phpunit

$ wget https://phar.phpunit.de/phpunit-6.0.phar
$ chmod +x phpunit-6.0.phar
$ sudo mv phpunit-6.0.phar /usr/local/bin/phpunit
$ phpunit --version