Optional: create lxc container

lxc launch images:centos/7 sql

You could stick with Debian if you want to, but i found it very, very impossibile to install MySQL on it due to AppArmor kicking in.

Please note i’ve split this on two LXC containers, two distributions, as i needed SQL up and running, and I didn’t really give a sh*t about the distributions they’re running. Mind that in CentOS, the apt-get gets replaced by yum.

So, for all what’s not SQL related:

lxc launch images:debian/buster lemp
lxc snapshot lemp 1
lxc exec lemp bash

Note, you might want to snap it once in a while during this if you mess things up a little bit…

First, my personal mandatory steps on debian:

apt-get update
apt-get upgrade
apt-get install vim htop lnav apt-utils iputils-ping

Up next, following the plan:

Install and configure Nginx and deploy PHP with fastCGI:

apt-get install nginx-full 
apt-get install php7.0 php7.0-cli php7.0-mysql php7.0-gd php7.0-json php7.0-curl php7.0-xml php7.0-fpm php-pear
systemctl start nginx php7.0-fpm
systemctl enable nginx php7.0-fpm

Make www folder:

mkdir /var/www/sandbox2.kes.ovh
vim /etc/nginx/sites-available/sandbox2.kes.ovh
~
server {
    listen 80;
    server_name sandbox2.kes.ovh;
    access_log /var/log/NGX-sandbox2.kes.ovh.access.log;
    error_log /var/log/NGX-sandbox2.kes.ovh.error.log;
    root   /var/www/sandbox2.kes.ovh/;
    index index.php index.html index.htm;
    location / {
        try_files $uri /index.html /index.php;
    }
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    }
}
~
ln -s /etc/nginx/sites-available/sandbox2.kes.ovh /etc/nginx/sites-enabled
systemctl restart nginx

Should be up and running now.

Up to MySQL@ That_Bloody_CentOS:

yum update
yum install vim wget
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum -y install mysql-server

systemctl enable mysqld
systemctl start mysqld

read few info at the bottom

systemctl stop mysqld

mysqld --skip-grant-tables --user=mysql

note, you must start it and stop it, otherwise the mysql table will not be generated.

second terminal window:

mysql -u root
USE mysql;
UPDATE mysql.user
    SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
    WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
exit

ps aux
kill [mySqlPID]

systemctl start mysqld

In case you want LAMP on CentOS, consider installing first MySQL (not MariaDB), then httpd package, php5.4 (sadly, from repos, i haven’t figured out how to get 7.1 so far, but i’m working on it), and then install phpMyAdmin. Here

And then… Migrate your data, i guess?

** the info at the bottom:**

At the time of writing, i did not know that there’s a temporary password set for root user. It’s readable at /var/log/mysqld.log. So this is also a quick “reset your SQL password” how-to. Anyways, make sure to first grep /var/log/mysqld.log | grep password to see if it’s there.