How to setup LAMP in linux

Now let’s Setup LAMP –

1st Way –

To install apache & mysql & php in one word type –

After this screen will ask you to give mysql root password you can give it as your choice.

Then finally for phpmyadmin type this in terminal –

Installation will prompt you to select the web server for automatic configuration. Use Spacebar to select the web server type and then press Enter.Next screen will prompt you for configuring database called db-common for phpMyAdmin. Use the tab key to select yes and Press Enter.Next it will prompt you to enter the password for MySQL root user,please enter the MySQL root password that created earlier during installation.It will prompt you to type the password for MySQL application password for phpmyadmin. If you left it blank, a random password will be generated. Type the password of your wish as same before and press Enter.Confirm your password in the next screen.

Then restart your apache type in terminal –

Then to Create another phpmyadmin user type in terminal –

Very Important After  you setup LAMP follow below steps –

Your need to configure your apache2 file for this you need to type in the terminal –


Then change like this and save –



Change line:

To look like this:

Change line:

To look like this:

Change line:

To look like this:

Then restart your apache type in terminal –

Now type below commands-

# How to install some app in one command-

# For Php 7.2 –

# To Check –

Now after everything done for some reason when you  restart the apache2 in terminal it shows some error msg. To solve the problem about localhost after restart the apache type following code in terminal –

Then type –

( In the blank page )


2nd way to install LAMP – In Brief

1. To start off we will install Apache.
2. Open up the Terminal (Applications > Accessories > Terminal).
3. Type this into Terminal and then press enter:

The Terminal will then ask you for your password, type it and then press enter.
4. Testing Apache
Open up any web browser and then enter the following into the web address: http://localhost/
You should see a folder entitled apache2-default/. Open it and you will see a message saying “It works!” , congrats to you! or something like that!
5. Install PHP5
Again open up the Terminal (Applications > Accessories > Terminal).
Type the following line of code into Terminal:

In order for PHP to work and be compatible with Apache we must restart Apache. Type the following code in Terminal to do this:

6. To check whether PHP5 works or not –
In the terminal type the following line :

This will open up a file called testphp.php.
Copy/Paste this line into the testphp file:

Save and close the file.
Now open your web browser and type the following into the web address: http://localhost/testphp.php
(It will show you the page that has all information about your php. If you have prior experience of installing php in some other OS, you must have seen this page.) Congrats you have now installed both Apache and PHP!
7.Install MySQL
Once again open up the amazing Terminal & type this line:

Type new root password for MySQL in the Next Screen.
Repeat the root password.
Step 2 (optional) – In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the my.cnf file.

Change the line

Step 3 (optional) – This is where things may start to get tricky. Begin by typing the following into Terminal:

Following that copy/paste or type this line:
mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘yourpassword’);
(Make sure to change your password to a password of your choice.) ( optional )
After setup LAMP then Install phpmyadmin:
We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste or type the following line into Terminal:

After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:

Now we are going to have to uncomment the following line by taking out the semicolon (;)
Change this line:

To look like this:

Now just restart Apache and you are all set :

Testing phpMyAdmin:
If you would like to manage the MySQL through phpMyAdmin, Open the Mozilla Firefox and Type the following web address.
http://localhost/phpmyadmin or
You will get MySQL login page, Please type the username and password set by you during MySQL installation.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.