Forum Sondria46®   →   Sondria46_Blog   →   Blog_Articles   →   How to install lamp server on ubuntu 20.04 ?

How to install lamp server on ubuntu 20.04 ?

Started by admin Oct 31st, 2024 at 00:14
admin
Admin
Posts: 95
Oct 31st, 2024 at 00:14

To install a LAMP (Linux, Apache, MySQL, PHP) server on Ubuntu 20.04, follow these steps :

 

  1. Update the Package Lists: Open a terminal window and update the package lists to ensure you have the latest information about available packages:

     
    sudo apt update
  2. Install Apache Web Server: You can install Apache using the apt package manager:

     
    sudo apt install apache2

    After the installation is complete, start Apache and enable it to start on boot:

     
    sudo systemctl start apache2 sudo systemctl enable apache2
  3. Install MySQL Server: You can install MySQL using the following command. During the installation, you will be prompted to set a root password:

     
    sudo apt install mysql-server

    After the installation is complete, start MySQL and enable it to start on boot:

     

     
    sudo systemctl start mysql sudo systemctl enable mysql

    You should also run the MySQL security script to improve the server's security:

    sudo mysql_secure_installation
  4. Install PHP: Install PHP and some commonly used PHP extensions:

     
    sudo apt install php libapache2-mod-php php-mysql
  5. Configure Apache for PHP: To configure Apache to work with PHP, you need to edit the Apache configuration file:

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

    Move the index.php file so it comes before index.html within the section. It should look like this:

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

    Save the file and exit the text editor.

  6. Restart Apache to apply the changes:

     
    sudo systemctl restart apache2
  7. Test Your LAMP Setup: Create a test PHP file to ensure that PHP is working correctly with Apache:

     
    echo "" | sudo tee /var/www/html/info.php

    You can access this file in your web browser by visiting http://your_server_ip/info.php. Replace your_server_ip with your server's IP address or domain name.

  8. (Optional) Secure MySQL Installation: You can further enhance the security of your MySQL installation by running the MySQL security script:

     
    sudo mysql_secure_installation

    This script will allow you to set a new root password, remove anonymous users, and more.

That's it! You've successfully installed a LAMP server on Ubuntu 20.04. You can now start building and hosting web applications on your server.

 
 
sudo mysql_secure_installation

Running sudo mysql_secure_installation is an important step in securing your MySQL installation on Ubuntu. When you run this command, you'll be guided through a series of prompts to improve the security of your MySQL server. Here's a step-by-step breakdown of what happens when you run sudo mysql_secure_installation:

  1. Set Root Password: You will be prompted to set a new root password for MySQL. This is the password you'll use to log in as the MySQL root user, which has administrative privileges. Enter a strong password and make sure to remember it.

  2. Remove Anonymous Users: You'll be asked if you want to remove anonymous MySQL users. It's a good idea to remove anonymous users, as they can potentially be a security risk. Answer "Y" (yes) to this prompt.

  3. Disallow Root Login Remotely: You'll be asked if you want to disallow root login from remote machines. It's generally a good security practice to disallow root login remotely. Answer "Y" (yes) to this prompt.

  4. Remove Test Database: You'll be asked if you want to remove the test database that is included by default with MySQL. Answer "Y" (yes) to this prompt. This is another security measure to prevent unauthorized access.

  5. Reload Privilege Tables: The script will reload the privilege tables to apply the changes you've made.

After completing these steps, your MySQL installation will be more secure. Make sure to keep your MySQL root password in a safe place, as it's essential for administrative tasks on the MySQL server.

« Last Edit: Oct 31st, 2024 at 00:17 by admin »


Home   •   FAQ   •   Support   •   Terms of Service   •   Privacy   •   News   •   Forum
Copyright © 2024 Sondria46®. All Rights Reserved.
Powered by EvolutionScript Version 6.6