Install the LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu

LAMP stack is an open source software group used to create web servers. The acronym comes from: Linux, Apache, MySQL, and PHP.

Below we will see how to install a private LAMP server on Ubuntu.

lamp server

Install Apache

Apache is a free open source software that runs over 50% of web servers across the globe.

To install Apache, open the terminal and type the commands:

sudo apt-get update sudo apt-get install apache2

That's it. To check if Apache is installed, open the address in your browser:

http://localhost, ή ή την τοπική διεύθυνση του υπολογιστή σας (π.χ.. Η σελίδα που θα ανοίξει θα σας δείξει ότι ο apache “Δουλεύει!”

apache LAMP

How to find your IP address?

Run the following command


Install MySQL

MySQL is a powerful database management system used to organize and retrieve data

To install MySQL, type in your terminal:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql php7-mysql

During installation, MySQL will ask you to set a root password. Type a password.

Once you have installed MySQL, you must enable it with the command:

sudo mysql_install_db

Finish setup by running the command:

sudo / usr / bin / mysql_secure_installation

You will be prompted for the root password.

Type it.

The script will then ask you if you want to change the root password. Proceed to the next steps by typing N

Say yes (Y) to all options. In the end, MySQL will need to reload to apply the new changes.

By default, installing MySQL has an anonymous user, allowing anyone
to connect to MySQL without having to have a user account. This is only for testing.
So you should remove access especially if you want to setup a public server.

Remove anonymous users? [Y / n] y
… Success!

Once you're done we can start by installing PHP.

Install PHP

PHP is an open web scripting language that is widely used to create dynamic web pages.

To install PHP, open the terminal and run the command

sudo apt-get install php7.0 php-pear libapache2-mod-php7.0 php7.0-mysql

After you answer yes twice, PHP will be installed.

We should add an index.php to the beginning of the index files:

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

Add the following and save and exit together press ctrl + X to select y and press enter

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

Now you have a LAMP stack on your computer.

View PHP on your server

Now that the LAMP is installed, we can see the items online by creating a quick info page with php

Create a new file:

sudo nano /var/www/info.php

Add the following line:

Then Save and Exit together press ctrl + X to select y and press enter.

Restart Apache to apply all changes:

sudo service apache2 restart

See your page:


Let's add the phpMyAdmin utility

Install phpMyAdmin

Run the command at the terminal

sudo apt-get install phpmyadmin php-mbstring php-gettext

In the server option, type apache2.
Select yes in the dbconfig-common question for creating a database
You will be asked for the database admin code
Select and confirm the password for the phpMyAdmin application itself

Enable PHP extensions mcrypt and mbstring with the following commands:

sudo phpenmod mcrypt sudo phpenmod mbstring

Make a restart on Apache:

sudo systemctl restart apache2

You can see the management page from the address of your choice by using / phpmyadmin at the end:



The user is the root and the code that you selected.




Note: The secure connection (HTTPS) we use locally will explain in another publication how to enable it.

Registration in via Email

Enter your email to subscribe to the email notification service for new posts.

Read them Technology News from all over the world, with the validity of

Follow us on Google News at Google news