Install Nginx, PHP, MySQL (Mariadb) on Ubuntu

-Would you be kind to me in which direction to go?
-In the famous you, – replied the cat.
-I don’t know it.
-So, in the unknown. In any case, it is known that in a known time you will find yourself therrre or herrre,-purring cat.

Nginx Installation:

apt update
apt install nginx

Installing PHP and the MariaDB driver

apt install php-fpm php-mysqlnd php-xml

Creating Virtual Domains

mkdir /var/www/
chmod -R 755 /var/www/

In the /etc/nginx/sites-available directory, we create a file

The contents of the file

server {
     listen 80;

     root /var/www/;

     # Add index.php to the list if you are using PHP
     index index.php index.html index.htm index.nginx-debian.html;
    location / {
               try_files $uri $uri/ =404;
               if (!-e $request_filename) {
                  rewrite ^.+/?(/wp-.*) $1 last;
            rewrite ^.+/?(/.*\.php)$ $1 last;
                  rewrite ^(.+)$ /index.php?q=$1 last;

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

Now you need to reboot the Webserver

service nginx restart

Checking PHP work

In /var/www/ , we will create the index.php file and write in it:

<?php phpinfo(); ?>

Next, open your website in the browser, in the example we use and if everything is done correctly, we see this picture:


sudo apt install mariadb-server mariadb-client

Security settings


Answer the questions:

Create a database and a user.

Entering the MARIADB:

mysql -u root

If you set the password to root:

mysql -u root -p
CREATE USER 'nameus'@'localhost' IDENTIFIED BY 'user_password';

For the user_password place, enter the user password.

GRANT ALL ON domaindb. * to nameus @ localhost;

Deploying WordPress

cd /var/www/
curl -O
tar xzvf latest.tar.gz
mv wordpress/* .
rmdir wordpress
chown -R www-data:www-data /var/www/
chmod -R 755 /var/www/