Install Linux, Apache, MySQL, PHP On Ubuntu 20.04 (LAMP)

Install Linux, Apache, MySQL, PHP On Ubuntu 20.04 (LAMP)

Tutorial to install Linux, Apache, MySQL, PHP On Ubuntu 20.04

We will go through the process of installing a LAMP stack on the Ubuntu 20.04 LTS operating system. LAMP stands for Linux, Apache, MySQL, and Php.

Install Linux, Apache, MySQL, PHP On Ubuntu 20.04 (LAMP)

We’ll install a LAMP stack or Linux, Apache, MySQL and Php on your Ubuntu 20.04 LTS.

Step 1:

Install Apache On Ubuntu 20.04 LTS

Steps to install the Apache webserver on Ubuntu 20.04 LTS. Execute the following command in the Ubuntu 20.04 LTS terminal to install Apache.

sudo apt update
sudo apt install apache2

Now adjust your firewall settings to allow HTTP and HTTPS traffic.

Run the following command to list out the available UFW application profiles.

sudo ufw app list

You will see output like this:

Available applications:
Apache
Apache Full
Apache Secure
OpenSSH

Apache: Only port 80 open.
Apache Full: Port 80 and port 443 open.
Apache Secure: Port 443 open.

Run the following command to allow traffic only on port 80.

sudo ufw allow in "Apache"

Open your browser and type your IP address. You will see the Ubuntu 20.04 default Apache web page.

Step 2:

Install MySQL on Ubuntu 20.04 LTS

MySQL is a popular database management system. Run the following command to install MySQL on Ubuntu.

sudo apt install mysql-server

Confirm installation by typing Y, and then ENTER.

When the installation is finished, let’s go through the security configuration.

sudo mysql_secure_installation

You will see a message where it asks if you want to configure the VALIDATE PASSWORD PLUGIN.

Answer Y for yes, or any other key for No.

READ More Relevant Stuff:  Install Plex Media Server On Ubuntu 18.04

If you answer “yes”, you’ll see the option of selecting the level of password validation. Follow the onscreen instruction to set a password.

Install Php On Ubuntu 20.04 LTS

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

php-mysql: To communicate with MySQL-based databases.

libapache2-mod-php : To enable Apache to handle PHP files.

Run the following command to confirm your PHP version:

php -v

How To Create Virtual Host In Ubuntu 20.04 LTS

Create the directory for your website or domain (localhost) as follows:

sudo mkdir /var/www/your_domain 

Now. Assign ownership of the directory with the $USER environment variable

sudo chown -R $USER:$USER /var/www/your_domain

Now, create a new file in  Apache’s sites-available directory:

sudo nano /etc/apache2/sites-available/your_domain.conf
Now, paste the following information in your new file your_domain.conf.

<VirtualHost *:80>
    ServerName your_domain
    ServerAlias www.your_domain
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save and close the file. For nano user, Press CTRL+X, then Y and ENTER.

Enable the new virtual host:

sudo a2ensite your_domain

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

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