I want to install the whole package of apache2, MySQL, PHP and phpmyadmin at a time on my ubuntu 14.04. I want to install the package from terminal. How to do it?


2 Answers 2


Let me try and give you a good brief run down on how you can do this. Before starting do a system update:

sudo apt update && sudo apt dist-upgrade or

sudo apt-get update && sudo apt-get dist-upgrade


  1. Linux:
    • installation of Ubuntu
  2. Apache:
    • from the terminal run sudo apt-get install apache2 or sudo apt install apache2 if you installed Ubuntu 16.04 or higher.
    • to confirm apache is up and running:
      • open your browser of choice and go to this address in the address bar: localhost/ and if it's installed you should see the image below

enter image description here

  1. Mysql:
    • From the terminal run sudo apt-get install mysql-server or sudo apt install mysql-server if you installed Ubuntu 16.04 or higher
    • Follow the terminal instruction to add a password
    • Secure the installation by running this after the complete install:
      • sudo mysql_secure_installation
  2. php:
    • Install withsudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
      • libapache2-mod-php allows apache parse php files
    • Run this sudo systemctl restart apache2 to restart apache so its incorporates php parsing functionality, then check if its running with the next step
    • sudo systemctl status apache2, you should see the image below if its running

enter image description here

  • Now php has many more modules that you can install. To see these by running this in the terminal sudo apt-cache search php7 or sudo apt search php7

    1. phpmyadmin:
      • this can be installed with:
      • sudo apt install phpmyadmin or sudo apt-get install phpmyadmin. This will install the official package, but if this doesn't work get it from here.
      • extract and drop it in /var/www/html. Change the folder name to _phpmyadmin__ and access it from the browser like this localhost/phpmyadmin

Now lets test your apache to see its working:

  • from terminal run: sudo vim /var/www/html/info.php, and put this in that file, or use nano if you prefer!

    <?php echo phpinfo(); ?>

Open a browser and put this [localhost/info.php] into your address bar and should see something like this:

enter image description here

Note: You can tweak your apache, mysql and php to suite your needs. This by no means all there is to setting up LAMP stack on your Ubuntu but its a start.

Source: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04

  • As in Feb,2020, (Ubuntu 18.04.2 LTS) everything is working fine with a few caveats: In step 3 the installation DOES NOT asks for a password, so I recommend to follow these instructions. And in step 4 the php-mcrypt is deprecated and I simply remove it (there are some workarounds, but for now I just bypass it). And finally, if you'd like to use the gui to create files at var/www/ I recommend read this. gl hf
    – PauloBueno
    Feb 29, 2020 at 14:11

You can accomplish this by simply typing two commands.

  • sudo apt-get install lamp-server^
  • sudo apt-get install phpmyadmin

The first one will install apache, php, and mysql all at once. including all dependencies needed for phpmyadmin, and other web-apps. Then the 2nd will install & integrate phpmyadmin.

You will be prompted by both for setting up mysql credentials & giving such credentials for phpmyadmin.

  • Thank you. It is easier. But I installed taskel first. As I didn't get this answer then. Dec 29, 2016 at 11:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.