Home ยป How to install LAMP (Linux, Apache, MariaDB, PHP) on Ubuntu

How to install LAMP (Linux, Apache, MariaDB, PHP) on Ubuntu

0 comment 115 views

Here’s a step-by-step guide on how to install LAMP (Linux, Apache, MariaDB, PHP) on Ubuntu:

Step 1: Update System

  1. Open a terminal window on your Ubuntu server.
  2. Run the following command to update the system packages:
sudo apt update
  1. If prompted, enter your sudo password to authenticate.

Step 2: Install Apache

  1. Run the following command to install Apache web server:
sudo apt install apache2
  1. After installation, Apache should start automatically. You can verify its status with the following command:
sudo systemctl status apache2
  1. Open a web browser and enter your server’s IP address or domain name to check if Apache is running. You should see the default Apache landing page, which confirms that Apache is successfully installed.

Step 3: Install MariaDB

  1. Run the following command to install MariaDB server:
sudo apt install mariadb-server
  1. During installation, you will be prompted to set a root password for MariaDB. Enter a strong password and remember it as you will need it later.
  2. After installation, MariaDB should start automatically. You can verify its status with the following command:
sudo systemctl status mariadb

Step 4: Install PHP

  1. Run the following command to install PHP and its necessary modules:
sudo apt install php libapache2-mod-php php-mysql
  1. After installation, you can verify PHP version with the following command:
php -v
  1. To test PHP, you can create a PHP info file. Run the following command:
sudo nano /var/www/html/info.php
  1. In the text editor, enter the following PHP code:
<?php phpinfo(); ?>
  1. Save and close the file.
  2. Open a web browser and enter the URL http://<your-server-ip>/info.php. You should see the PHP info page, which confirms that PHP is working correctly.

Step 5: Configure MariaDB

  1. Run the following command to configure MariaDB:
sudo mysql_secure_installation
  1. Follow the on-screen prompts to set additional security measures for MariaDB, such as removing anonymous users, disabling remote root login, and removing test databases. It is recommended to follow the prompts to enhance the security of your MariaDB installation.

Congratulations! You have now successfully installed LAMP (Linux, Apache, MariaDB, PHP) stack on your Ubuntu server. You can proceed to build and host your web applications using this environment.

Leave a Comment