Default Linux, Nginx, MariaDB, PHP7.0 & Adminer stack on Ubuntu 16.04
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nginx
sudo systemctl enable nginx
sudo systemctl start nginx
systemctl status nginx
Now in your browser’s address bar, type http://localhost
or http://127.0.0.1
and hit enter
You will see "Welcome to nginx!, that means nginx installed and running successfully.
sudo chown www-data /var/www/html -R
sudo apt-get install mariadb-server mariadb-client
systemctl status mysql
sudo systemctl enable mysql
sudo mysql_secure_installation
When it asks you to enter MariaDB root password, press enter
because you have not set the root password yet. Then enter y
to set the root password for MariaDB server.
Next just press Enter to answer all the remaining questions. This will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security.
sudo apt-get install php7.0-fpm php7.0-mbstring php7.0-xml php7.0-mysql php7.0-common php7.0-gd php7.0-json php7.0-cli php7.0-curl php7.0-intl php7.0-bcmath php7.0-mcrypt
sudo systemctl start php7.0-fpm
systemctl status php7.0-fpm
sudo rm /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/conf.d/default.conf
server {
server_name localhost;
root /var/www/html/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location /opensourcepos {
try_files $uri $uri/ /opensourcepos/public/index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
sudo nginx -t
sudo service nginx restart
php --version
sudo nano /var/www/html/php_info.php
<?php phpinfo(); ?>
Now in the browser address bar, enter localhost/php_info.php
. You should see your server’s PHP information. This means PHP is workinging fine. For your server’s security, you should delete php_info.php file now.
Adminer is a free opensource data base management tool like phpmyadmin. It is very ightweight and easy to install and also supports various themes. Download Adminer from here:
https://github.com/vrana/adminer/releases/download/v4.2.5/adminer-4.2.5.php
Place it in var/www/html folder.
To access it, type in your browser localhost/adminer-4.2.5.php
Your Linux OS has a root user. MariaDB also has a root user. So sometimes, when you try to log into MariaDB monitor as root user, MariaDB may authenticate you via the Unix_Socket plugin
but this plugin is not installed by default. So you see Plugin 'unix_socket
' is not loaded Error.
First stop MariaDB, use this command to stop it.
sudo systemctl stop mysql
sudo mysqld_safe --skip-grant-tables &
mysql -u root
MariaDB [(none)]> select Host,User,plugin from mysql.user where User='root';
You will see it’s using unix_socket
plugin. To change it to mysql_native_password
plugin, execute this command:
MariaDB [(none)]> update mysql.user set plugin='mysql_native_password';
flush privileges;
quit;
sudo kill -9 $(pgrep mysql)
sudo systemctl start mysql
mysql -u root -p
If you face any issue, please see Issue 546.