Installing LAMP on Pi4

Posted under » Apache » Raspberry Pi on 5 May 2022

A pi4 is (barely) strong enough to host a LAMP server.

Unlike Ubuntu, there is no shortcut so best to install in the order of Apache, PHP and MariaDB. Install Apache.

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt install apache2 -y

Then PHP 7.4 (latest) as of writting.

$ apt install php7.4 libapache2-mod-php7.4 php7.4-mbstring php7.4-mysql php7.4-curl php7.4-gd php7.4-zip -y

As usual, you can install other PHP libraries.

Finally, MariaDB if you prefer over MySQL

$ apt install mariadb-server
$ mysql_secure_installation 

The last command is useful because by default, MySQL is installed without any password set up meaning you can access the MySQL server without any authentication.

In Ubuntu Server, the LAMP server will start automatically but in Raspberry pi OS Pi4, you need to start Apache and MariaDB manually. This works for me because Pi4 is low powered.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS IOT