• WordPress
  • cPanel
  • Softaculous
  • KVM Virtualization
  • Vmware Virtualization
  • Proxmox
Monday, May 12, 2025
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
No Result
View All Result
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux
LinuxBoost
  • Home
  • Almalinux
  • CentOS
  • Debian
  • Fedora
  • Ubuntu
  • Red Hat Enterprise Linux
  • Rocky Linux
  • OpenSUSE
  • Arch Linux
  • Oracle Linux

How to Install and Configure LAMP Stack on Ubuntu: A Complete Tutorial

in Linux OS, Ubuntu
How to Install and Configure LAMP Stack on Ubuntu

If you are looking to set up a web server on Ubuntu, you will likely need to install and configure a LAMP stack. LAMP stands for Linux, Apache, MySQL, and PHP, and it is the most popular web development platform used today. In this tutorial, we will guide you through the process of installing and configuring LAMP stack on Ubuntu.

Prerequisites:

Before we begin, you will need to ensure that you have the following:

  • A server running Ubuntu 18.04 LTS or later.
  • A non-root user with sudo privileges.

Step-1: Install Apache

Apache is a popular web server that can be used to serve web pages. To install Apache, open up a terminal window and run the following command:

sudo apt-get update
sudo apt-get install apache2

After the installation is complete, start the Apache service by running:

sudo systemctl start apache2

To check if Apache is running, open up a web browser and enter your server’s IP address. You should see the Apache2 Ubuntu Default Page.

Step-2: Install MySQL

MySQL is a popular relational database management system that is used to store and manage data. To install MySQL, run the following command:

sudo apt-get install mysql-server

During the installation process, you will be prompted to set a root password for MySQL. Make sure to set a strong password and keep it safe.

After the installation is complete, start the MySQL service by running:

sudo systemctl start mysql

To secure your MySQL installation, you can run the following command:

sudo mysql_secure_installation

This command will prompt you to configure several security options for your MySQL installation.

Step-3: Install PHP

PHP is a popular scripting language that is used to create dynamic web pages. To install PHP, run the following command:

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

After the installation is complete, restart the Apache service by running:

sudo systemctl restart apache2

To test if PHP is working properly, create a new file called info.php in the /var/www/html directory with the following content:

<?php
phpinfo();
?>

Save the file and open up a web browser. Enter the following URL: http://your_server_ip_address/info.php. You should see a PHP info page that displays information about your PHP installation.

Step-4: Configure Firewall

By default, Ubuntu comes with a firewall called UFW (Uncomplicated Firewall). To allow traffic to your web server, you will need to configure UFW to allow incoming traffic on ports 80 (HTTP) and 443 (HTTPS).

In order to allow HTTP traffic, run the following command:

sudo ufw allow 80/tcp

To allow HTTPS traffic, run the following command:

sudo ufw allow 443/tcp

After allowing the traffic, you can check the status of the firewall by running:

sudo ufw status

Step-5: Conclusion

Congratulations! You have successfully installed and configured a LAMP stack on Ubuntu. You can now start developing and deploying web applications on your server.

In this tutorial, we have covered the installation and configuration of Apache, MySQL, PHP, and UFW. We hope that this tutorial has been helpful to you, and we encourage you to continue learning and exploring the vast world of web development.

How to set up a web server on Ubuntu using Nginx

ShareTweet
Previous Post

Best Command line Tools to Monitor MySQL Performance in Linux

Next Post

Ubuntu Security Essentials: How to Protect Your System from Threats

Related Posts

How to Install Tomcat on Rocky Linux

How to Install Apache Tomcat on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Set up NTP Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

How to Install Bacula Backup Server on Rocky Linux

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Golden Host VPS
  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.

  • Privacy Policy
  • Terms and Conditions
  • About Us
  • Contact Us

Copyright © 2023 linuxboost.com All Rights Reserved.