Welcome to Uddoyon, in this article we try to know about LAMP (Linux, Apache, MySQL, and PHP) Installation on Ubuntu System so keep reading…
The LAMP stack, consisting of Linux, Apache, MySQL and PHP, is a powerful combination that allows you to set up a web server environment for hosting dynamic websites and applications. In this guide, we will walk you through the process of installing a LAMP stack on an Ubuntu system.
Step 1 – Update and Upgrade:
Before you begin, it’s important to ensure your system is up-to-date. Open a terminal and enter the following commands:
sudo apt update
sudo apt upgrade
Step 2 – Install Apache:
Apache is a popular web server software that serves your web content to visitors. Install it using the following command:
sudo apt install apache2
Step 3 – Secure Apache:
Once Apache is installed, you can enhance its security by running:
sudo ufw allow 'Apache'
Step 4 – Install MySQL:
MySQL is a relational database management system. Install it with:
sudo apt install mysql-server
Step 5 – Install PHP:
PHP is a server-side scripting language used for creating dynamic web pages. Install PHP and necessary modules:
sudo apt install php libapache2-mod-php php-mysql
Step 6 – Configure PHP:
You can adjust the PHP settings by editing the php.ini file. Use your preferred text editor, like nano or vim:
sudo nano /etc/php/7.4/apache2/php.ini
Make any necessary changes and save the file.
Step 7 – Test PHP:
Create a PHP test file to ensure that PHP is working properly:
sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Step 8 – Secure MySQL:
MySQL comes with a script that can help improve its security. Run:
Follow the prompts to set a stronger root password, remove anonymous users, disallow remote root login, and remove test databases.
Step 9 – Virtual Hosts (Optional):
You can set up virtual hosts to host multiple websites on a single server. Create a virtual host file for each site in the
directory and enable them using “a2ensite”.
Step 10 – Restart Services:
After making changes, restart Apache for them to take effect:
sudo systemctl restart apache2
Congratulations! You have successfully installed a LAMP stack on your Ubuntu system. You now have a robust environment for hosting and developing websites and applications.
Thanks for Reading, stay with us to know more things as like this.