Linux MintUbuntu Based

How To Install LAMP on Linux Mint 22

Install LAMP on Linux Mint 22

In this tutorial, we will show you how to install LAMP on Linux Mint 22. The LAMP stack, a powerful combination of Linux, Apache, MariaDB, and PHP, is the backbone of many web development projects. This open-source software bundle provides a robust and flexible environment for hosting dynamic websites and web applications. Linux Mint 22, a user-friendly and stable Linux distribution, is an excellent choice for setting up a LAMP stack.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the LAMP stack on Linux Mint 22.

Prerequisites

  • A server running one of the following operating systems: Linux Mint 22.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • Basic familiarity with the Linux terminal and command-line interface.
  • An active internet connection.
  • Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.

Install LAMP on Linux Mint 22

Step 1. Update Your Linux Mint System.

To begin, it’s crucial to update your Linux Mint 22 system to the latest available versions of all packages. This step ensures that you have access to the most recent security patches, bug fixes, and software updates. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade

Once the update process is complete, it’s a good practice to reboot your system to apply any necessary changes:

reboot

Step 2. Installing Apache Web Server.

Apache is a powerful and widely used web server that forms the foundation of the LAMP stack. To install Apache on your Linux Mint 22 system, follow these steps:

Open the terminal and run the following command:

sudo apt install apache2

After the installation is complete, verify that Apache is running by executing:

sudo systemctl status apache2

If Apache is running correctly, you should see an output indicating that the service is active and running.

To test your Apache installation, open a web browser and enter http://localhost or your server’s IP address. If the installation was successful, you will see the default Apache landing page.

Step 3. Installing MariaDB Database Server.

MariaDB is a robust and reliable open-source database management system, that serves as a drop-in replacement for MySQL. To install MariaDB on your Linux Mint 22 system, follow these steps:

Open the terminal and run the following command:

sudo apt install mariadb-server

After the installation is complete, it’s recommended to run the MariaDB secure installation script to set up basic security measures:

sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disable remote root login, and remove the test database.

To verify that MariaDB is running correctly, use the following command:

sudo systemctl status mariadb

You should see an output indicating that the MariaDB service is active and running.

Step 4: Installing PHP 8.3.

PHP is a server-side scripting language that powers dynamic web content in the LAMP stack. To install PHP 8.3 on your Linux Mint 22 system, follow these steps:

Open the terminal and run the following command:

sudo apt install php libapache2-mod-php php-mysql

After the installation is complete, verify the PHP version by running:

php -v

You should see the installed PHP version displayed in the output.

To test your PHP installation, create a new file named phpinfo.php in the Apache document root directory:

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php

Open a web browser and access http://localhost/phpinfo.php. If PHP is installed correctly, you will see a detailed PHP configuration page.

PHP comes with a wide range of modules and extensions that extend its functionality. To install commonly used PHP extensions, you can use the following command:

sudo apt install php-curl php-gd php-mbstring php-xml php-zip

Step 5. Configure the Firewall.

Configuring your firewall is an essential step in securing your LAMP server. Linux Mint 22 comes with the UFW (Uncomplicated Firewall) utility, which simplifies firewall management. To allow Apache through the firewall, follow these steps:

Open the terminal and run the following command:

sudo ufw allow 'Apache Full'

This command allows incoming traffic on port 80 (HTTP) and port 443 (HTTPS) for Apache.

Verify the firewall status by running:

sudo ufw status

Step 6. Testing the LAMP Stack.

With all the components of the LAMP stack installed and configured, it’s time to test the setup to ensure that everything is working harmoniously. One way to do this is by creating a simple PHP script that connects to the MariaDB database and retrieves information. Follow these steps:

Create a new PHP file named db_test.php in the Apache document root directory:

sudo nano /var/www/html/db_test.php

Add the following PHP code to the file:

Add the following PHP code to the file:

<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "your_database";

// Create a connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

Save the file and exit the text editor.

Open a web browser and access http://localhost/db_test.php. If the LAMP stack is set up correctly, you should see the message “Connected successfully” displayed on the page.

Congratulations! You have successfully installed LAMP. Thanks for using this tutorial to install the latest version of the LAMP stack on the Linux Mint system. For additional help or useful information, we recommend you check the official LAMP website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button