2 Ways to Install LAMP Server on Ubuntu 22.04 | 20.04

Check out the easiest way to install LAMP server (Linux, Apache, MySQL and PHP) on Ubuntu 22.04 LTS Jammy Jelly Fish or Ubuntu 20.04 Focal Fossa Linux using command terminal.

Whenever it comes to having a web server for business purposes, the first name that comes up is Apache. It is one of the best open source web servers readily available to be installed on any Linux system. However, there are many web applications that require little more than Apache web servers to run smoothly, such as WordPress – it’s a PHP-based CMS. Therefore, to use it on our Linux, we need a bunch of server applications. For example to serve dynamic web pages – PHP language; to store MySQL/MariaDB data. So, the stack of all these platforms is known as LAMP server.

Software components are usually installed on physical or virtual servers. Static or dynamic web content can be delivered with a LAMP system. Typical application areas for LAMP-based servers are websites or online shops created using content management systems (CMS).

Software components are freely available and minimize the cost of building the server environment. Since the software code is open-source, programmers can develop their own extensions or make modifications. LAMP servers offer a high degree of flexibility.

Variants and alternatives to LAMP

All LAMP components in the LAMP environment are replaceable. Operating systems, web servers, database management systems and scripting languages ​​can be exchanged. Here are some alternative LAMP environments with OS support

WAMP (Linux operating system has been replaced by Microsoft Windows but cannot be used for commercial purposes. Only for local development)

MAMP (Linux operating system has been replaced by Apple’s macOS, not for commercial use)

LAPP (MySQL database management system has been replaced by PostgreSQL; can be used for commercial applications)

PML (Apache web server is replaced by Nginx web server)

Steps to Install LAMP Server on Ubuntu 22.04 | 20.04 LTS

The commands given here can be used for other operating systems and similar versions of Ubuntu such as 18.04, including Debian.

1. Requirements

Ubuntu 20.04 or 22.04 Linux
• At least one non-root user with sudo access
• Command terminal
• Internet connection

#ist way to install LAMP server using tasks

2. Install Tasksel on Ubuntu

Well, Tasksel is a program on Ubuntu available through the system repository to install server application stacks, easily using the command. Therefore, first install it on your Ubuntu 22.04 or 20.04 LTS system.

sudo apt install tasksel

3. Install LAMP Server on Ubuntu 22.04 or 20.04

Then we can use “Tasksel” command tool to easily install Apache, MySQL and PHP. This will also start and activate all required services. We don’t need to manually configure individual LAMP components. Hence, opt for the given command:

sudo tasksel install lamp-server

Where

For an intuitive interface, use:

sudo tasksel

To select LAMP server from the intuitive text wizard.

Use your arrow key and select “lamp-server” after that, press the Tab key to select the Okay button then press the Enter key.

Wait a few minutes and the LAMP server will be on your Ubuntu Linux.

#2nd method install LAMP components individually

Well, if you don’t want to use the Tasksel method, use the APT package manager to install the LAMP server components individually one by one. And we also have to activate the services manually.

4. Install Apache web server

As we discussed at the beginning of the tutorial, the packages to install the Apache web server are already available through the default system repository. Therefore, running a single command may do the trick.

sudo apt install apache2

Once the installation is complete, we can activate and start the web server services.

To start and activate Apache:

sudo systemctl start apache2

And for having it enabled, so that the service can work with system startup.

sudo systemctl enable apache2

To check the service status

sudo systemctl status apache2

5. Install MySQL/MariaDB database server

By using Tasksel we will automatically get the MySQL database instead of MariaDB. Therefore, if you want the MariaDB database, use the manual installation method given here.

For MySQL

sudo apt install mysql-server

To start and activate the service:

sudo systemctl enable --now mysqld

To status:

sudo systemctl status mysqld

Where

For MariaDB:

For those who want MariaDB instead of MySQL, the command will be:

sudo apt install mariadb-server

Activate and start the service:

sudo systemctl enable --now mariadb

6. Configure PHP on Ubuntu 22.04 | 20.04

The final component of the LAMP stack environment is PHP. It is a popular server-side scripting language required to run PHP-based web applications.

The given command will install the latest PHP version available in your Ubuntu OS repository.

sudo apt install php libapache2-mod-php

Install some common PHP extensions:

sudo apt install php-{curl,intl,zip,soap,xml,gd,mbstring,bcmath,common,mysqli}

Activate the rewrite module:

sudo a2enmod rewrite

Restart the Apache web server:

sudo systemctl restart apache2

Conclusion:

So here are some common ways to install and start working with LAMP environment on Ubuntu 22.04 or 20.04 Linux systems using command terminal. After configuring LAMP, you can start configuring various web applications such as Joomla, WordPress or CRMs. Well, this guide is only for setting up LAMP, but there are also other things like setting up virtual host, web directory, etc. that we can learn while setting up a Web application.

Other tutorials:

How to Install LAMP on Rocky Linux 8 Server
Enable OpenSSH Server on Ubuntu 22.04
How to Install KDE Plasma on Debian 11 Bullseye Linux
Install Apache, MySQL and PHP on AlmaLinux 8

About Jon Moses

Check Also

Intel promises “substantial contributions” to the growth of RISC-V • The Register

Analysis Here’s something that would have seemed odd just a few years ago: to help …