2. How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1
How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1

2. How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1

Install Apache, MySQL and PHP on Ubuntu is not difficult. The LAMP stack is a popular open source web development platform that can be used to run and use dynamic websites and web-based applications. Typically, the LAMP stack consists of Apache web servers, MariaDB / MySQL databases, the PHP / Python / Perl programming language. LAMP is an acronym from Linux, MariaDB / MYSQL, PHP / Python / Perl. This tutorial explains how to install Apache, MySQL, PHP (LAMP stack) on the Ubuntu 18.04 LTS server.

How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 1

For this tutorial, just follow the following steps. Please open a Terminal in each of your Ubuntu.

1. Install Apache

For the first time, please update ubuntu with syntax:

And then for upgrading :

And then Install Apache Server :

Then check whether the apache2 service is running correctly:

Example output from syntax above is:

Congratulations, your Apache is active. Then provide access to the firewall for Apache: For default settings of Ubuntu 18.04, Apache is not allowed by the firewall to be remote / accessed from outside. Let’s look at the list of applications that are allowed by the firewall.

Then it will appear as follows:

Then run the following syntax:

Now try running the Apache webserver in the browser by accessing http://ip_address or http://localhost. If it works well, that means we have installed apache and the configuration has been completed.

2. Install MySQL

Please run the following syntax on your ubuntu terminal:

Then verify whether the mysql service is running well:

If it appears like this, it means your MySQL service is running well.

Congratulations your MySQL service has been going well. Then let’s set the User Administrator (ROOT) account for your Ubuntu. By default, mysql on ubuntu has an empty password. But we must add a password for our root passwort. We are required to secure our mysql server by running the following syntax:

Recommended  Prevent XSS Injection Attacks On PHP Easily

You will be asked if you want to set the VALIDATE PASSWORD plugin or not. This plugin allows users to configure strong passwords for database credentials. If enabled, It will automatically check the strength of the password and force the user to only set a password that is safe enough. It’s safer if we disable this plugin. However, you must use a strong and unique password for the database credentials. If you don’t want to activate this plugin, just press any key to skip the password validation section and continue the next steps.

If your answer is Yes, you will be asked to choose a level of password validation.

Validation of available passwords is low, medium and strong. Just enter the appropriate number (0 for low, 1 for medium and 2 for strong password) and press the ENTER button.

Now, enter the password for the MySQL root user. Please remember that you have to use a password for mysql root users depending on the password policy you chose in the previous step. If you do not activate this plugin, just use a strong and unique password of your choice.

After you enter the password twice, you will see the strength of the password (In our case it is 50). If you agree, press Y to continue with the password provided. If not satisfied with the password length, press the other button and set a strong password. If you agree with my current password, so I choose y.

For the rest of the questions, just type y and press ENTER. This will delete anonymous users, prohibit remote root user logins and delete the test database.

Congratulations, the password for your MySQL ROOT user has been set. Now continue to change the Authentication Method for the Root user. By default, the MySQL root user is set to authenticate using the auth_socket plugin in MySQL 5.7 and newer versions on Ubuntu. Although it increases security, it will also be difficult when you access your database server using any external program, for example phpMyAdmin. To fix this problem, you need to change the authentication method from auth_socket to mysql_native_password. To do this, enter your MySQL prompt using the command:

Run the following command at the mysql prompt to find the current authentication method for all mysql user accounts:

Then the output is as follows:

Look at this picture :

MySQL1
will shown like this

As you can see, the mysql root user uses the auth_socket plugin for authentication.

To change this authentication to the mysql_native_password method, run the following command at the mysql prompt. Don’t forget to replace “password” with a password of your choice that is strong and unique. If you have activated the VALIDATION plugin, make sure you have used a strong password based on current policy requirements.

Now please update what we have just run:

Now check again whether the authentication method was changed or not using the command :

Look at this image :

MySQL2
Will shown like this

Great!!! now the root user has access to all mysql shells. Please close mysql by adding the following syntax:

Congratulations, your MySQL server is running well.

3. Install PHP

Because this article is too long, I divided this article into 2 parts. Please continue reading at:

How to Install Apache, MySQL and PHP in Ubuntu 18.04 LTS Part 2

[Total: 2    Average: 5/5]

Detri Amelia Chandra

Hello, I introduce myself Detri Amelia Chandra. Some of my expertise is in System Analysis, Database Design, Artificial Neural Networks and a little in Programming. Check out my thoughts about the world on my blog. I updated this blog a bit rarely, so please keep visit my blog here often ...

This Post Has 2 Comments

Leave a Reply

Close Menu