I’m using CentOS for years (recently started to write about it even on this blog) but since all this fuss about CentOS Stream started, as everyone else, I started to look at viable options – Ubuntu Server being one of them. I will start my journey into Debian/Ubuntu by installing LAMP stack
Before we begin
This will be done on Ubuntu Server 20.04 with IP 192.168.60.3
First we will make sure our Ubuntu Server installation is up to date by typing in
sudo apt update
sudo apt upgrade
We also need to enable firewall and open some ports…
sudo ufw allow ssh
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
Installing Apache2
We will now go ahead to install and test Apache web server.
sudo apt install apache2
Lets see if the apache is running
sudo systemctl status apache2
Everything is ok.
I will also check statua by entering IP of the web server into the web browser on the machine in local network.
I will enter http://192.168.60.3 since my Ubunte LAMP server is on that IP address.
Success!!
Installing PHP 7.4
Next step is going to be installation of PHP module.
sudo apt install php8.1 php8.1-mysql php-common php8.1-cli php8.1-common php8.1-opcache libapache2-mod-php8.1
These are old screenshots from v7 of PHP, that should not bother you, everything works the same, only version is newer.
Lets check installation and version of PHP
php --version
We also need to restart Apache for changes to take effect.
sudo systemctl restart apache2
We will also test php functionality by entering following
echo '<?php phpinfo(); ?>' | sudo tee -a /var/www/html/phpinfo.php > /dev/null
Again, back to my client, I will enter into browser
http://192.168.60.3/phpinfo.php
Ok, website loaded without any errors or additional messages. Now that we know everything is ok, we need to remove our php test file. Publicly accessible PHP info can make easier attacks to your web.
sudo rm /var/www/html/phpinfo.php
The webpage we tested above now should not work.
Install MariaDB
Finally, we will install database to our web server.
sudo apt install mariadb-server mariadb-client
We will now check the status of installed db server
sudo systemctl status mariadb
Before we wrap up, we should secure our MariaDB by executing
sudo mysql_secure_installation
We will select to set root password by entering y and then defining new root password.
We will also enter y to remove anonymous users.
Remote root login should also be removed by entering y and all test dbs and data should be removed by entering y.
With this step, we are done, we have successfully installed LAMP stack on Ubuntu Server 20.04