How to Install LAMP Stack (Linux, Apache, MySQL, PHP) on Ubuntu 18.04


Easily deploy your favorite applications in seconds at an unbeatable price for your next projects.

Installing LAMP Stack on Ubuntu 18.04

The LAMP stack is a popular open-source web development platform that includes Linux as the operating system, Apache as the web server, MySQL as the database management system, and PHP as the scripting language. This guide will walk you through the installation process on Ubuntu 18.04.

Step 1: Update Package Repositories

Before installing any software, it's important to update the package repositories on your Ubuntu system. Open a terminal and execute the following command:

sudo apt update

Step 2: Install Apache

Apache is a widely-used web server that will host your website. To install Apache, run the following command:

sudo apt install apache2

Step 3: Configure Firewall

Allow incoming traffic on port 80, which is the default HTTP port. Execute the command:

sudo ufw allow 'Apache'

Step 4: Install MySQL

MySQL is a popular database management system that will store your website's data. Install MySQL by running the following command:

sudo apt install mysql-server

During the installation, you will be prompted to set a password for the MySQL root user.

Step 5: Install PHP

PHP is a powerful scripting language that is used to dynamically generate web pages. Install PHP and its required modules with the command:

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

Step 6: Configure Apache for PHP

To enable PHP processing with Apache, you need to modify the dir.conf file. Open the file using the command:

sudo nano /etc/apache2/mods-enabled/dir.conf

Move the PHP index file index.php to the first position so that it takes precedence over index.html. The file should look like:

    DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

Save the file and exit the text editor.

Step 7: Restart Apache

After making any configuration changes, you need to restart Apache for the changes to take effect. Execute the following command:

sudo systemctl restart apache2

Step 8: Test PHP Processing

Create a PHP test file in the Apache root directory with the command:

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

Add the following PHP code to the file:


Save the file and close the text editor.

Now, you can test to see if PHP processing is working correctly by visiting http://your_server_ip/info.php in a web browser. You should see a page displaying PHP configuration information.

That's it! You have successfully installed the LAMP stack on your Ubuntu 18.04 system. Now, you can begin developing and hosting your website using this powerful web development platform.

Installing LAMP Stack
LAMP Stack Linux
LAMP Stack Apache
Installing LAMP Stack on Ubuntu 18.04
LAMP Stack Ubuntu
LAMP Stack installation
Ubuntu LAMP Stack
LAMP Stack setup

Why Customers Love Us

What our customers say about us

Ready To Get Started For Free?

Create your free account today.