Ubuntu 20 install PHP-FPM 8, Nginx and MySQL 8

In this tutorial you'll learn how to create a webserver with PHP-FPM 8, Nginx and MySQL 8

If you are using Hetzner, make sure you add your public key when you create the server so you can ssh into without a password

Connect to the server as root

ssh root@<server-ip>

Update the system and install some useful tools

apt-get update
apt-get upgrade

# install tools
apt-get install unzip zip mc tree jq curl wget ntp gpg

Now, we need to create a normal user that we'll use to connect to our server from now on

# create a user without a password
adduser web -q --disabled-password

# go to user home directory
cd /home/web/

# copy .ssh directory from root to the user to allow access to your user
cp -av /root/.ssh/ .

# change permissions on the /home/web/.ssh/ directory
chown web:web -R .ssh/

Another step we need to do as root, is to allow the user to become root. Run the following command as root:

echo "web ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/web

Logout CTRL+D and connect back to server as web user

ssh web@<server-ip>

Install PHP-FPM 8

sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get update

sudo apt install -y php8.0-fpm php8.0-xml php8.0-mbstring php8.0-mysql

# install composer
curl -sS https://getcomposer.org/installer | php && sudo mv composer.phar /bin/composer

Install Nginx web server

To install nginx webserver you just have to run the following command, then all settings for nginx you'll find in /etc/nginx/ directory:

sudo apt install -y nginx

Install MySQL 8

To install MySQL 8 you need to download the debian package and then install it with dpkg

wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb

# the following command will be interactive and you can select mysql 8 or mysql 5.7
sudo dpkg -i mysql-apt-config_0.8.11-1_all.deb

If you run Ubuntu 20.04 it might be necessary to run the following command to register the package key

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29

Install mysql 8.0

sudo apt-get update
sudo apt install -f mysql-client=8.0* mysql-community-server=8.0* mysql-server=8.0*

Install server-manager application

Next, let's create the server directory. Is the place where we'll keep our websites:

sudo mkdir /home/server
sudo chown web:web -R /home/server

Let's go into the /home/server directory and configure our server manager console application:

# go to server directory
cd /home/server

# clone the manager application
git clone https://gitlab.com/kisphp/server-manager.git

# go inside the application directory
cd server-manager/

# install all application dependencies
composer install

Create the website

Create website directory

app/console site:create admin.example.com public

# create a dummy index.php file
cat <<EOF > public/index.php



Configure a Wordpress website

Follow the next steps to configure a Wordpress website:

# go to server manager
cd /home/server/server-manager

# create the wordpress site location
app/console site:create wp.demo.local

# download latest wordpress
wget https://wordpress.org/latest.zip -O /tmp/wordpress.zip

# unzip wordpress archive
unzip /tmp/wordpress.zip

# move files to the public directory location
mv wordpress/* /home/server2/wp.demo.local/public/

# delete current wordpress empty directory
rm -rf wordpress

# create database and user for our new wordpress (replace with real database name, username and password)
app/console db:create wp_demo wp_user wp_pass

# activate nginx configuration for the new website
sudo app/console nginx:activate wp.demo.local -w