Hello world!
In this blog, I am going to explain how to install Apache, Mysql, and PHP in your Linux (Ubuntu) OS. I am specifically writing this blog only for ubuntu users.

It’s a 3-step procedure to install the Apache webserver, Mysql server and PHP

Step1: Installing Apache

Step2: Installing MySQL

Step3: Installing PHP

These steps will get your system ready with LAMP stack

Step1: Installing Apache

Apache is one of the most popular web servers in the world. There are also so many alternatives but the web server which you want can be dependent on the purpose of usage. Let us discuss other web servers in other blogs, for now, let’s stick on to Apache.
For more information about Apache Click here.

Install Apache using Ubuntu’s package manager

sudo apt update
sudo apt install apache2

The purpose of first step is to update your repositories to the latest version available. The second step install’s apache2 in your OS.

Now apache is ready if you type or localhost in your browser you will see the default Ubuntu Apache web page, which is there for informational and testing purposes. It should look something like below image


Step2: Install MySQL

MySQL is a database management system. It is used to store data.

sudo apt install mysql-server

This will install mysql-server and When the installation is complete, run a simple security script that comes pre-installed with MySQL which will remove some dangerous defaults and lock down access to your database system.

sudo mysql_secure_installation

Then it will ask you

VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No:

I would recommend y|Y to set password for your MySQL

There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 

I would suggest to select 1 and then type your password

This is more than enough to start with MySQL, if you still want to secure your MySQL to login as root with password follow these steps

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

This will make your MySQL much more secure

Step3: Installing PHP

In addition with php installation, include some helper packages so that PHP code can run under the Apache server and MySQL database:

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

That’s it now your OS has the LAMP stack ready.

If you want to check whether PHP is installed or not type the following command

php -v

It will give you the PHP version installed in your OS.



No responses yet

Leave a Reply

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