sudo apt-get updatesudo apt-get install nginx
systemctl status nginxNote: This might say "software-properties-common is already the newest version"
sudo apt-get install software-properties-commonsudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://sfo1.mirrors.digitalocean.com/mariadb/repo/10.1/ubuntu xenial main'apt-get install will ask for root password to be set
sudo apt-get update
sudo apt-get install mariadb-serverFirst, make sure MariaDB is not running. Then, configure MariaDB:
sudo systemctl stop mysql
sudo mysql_install_db
sudo systemctl start mysql
sudo mysql_secure_installationFinally, make sure it's running:
mysql -v
mysql -uroot -psudo apt-get install php-fpm php-mysqlsudo vi /etc/nginx/sites-available/defaultserver {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com
root /var/www/html;
index index.php index.html;
include snippets/restrictions.conf;
location / {
try_files $uri $uri/ =404;
}
include snippets/fastcgi-php.conf;
}sudo vi /etc/nginx/snippets/restrictions.conflocation = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}sudo vi /etc/nginx/snippets/fastcgi-php.conflocation ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}Test for errors, then reload config:
sudo nginx -t
sudo systemctl reload nginx