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
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
LAMP:
- Linux:
- installation of Ubuntu
- Apache:
- from the terminal run
sudo apt-get install apache2orsudo apt install apache2if 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
- open your browser of choice and go to this address in the address bar:
- from the terminal run
- Mysql:
- From the terminal run
sudo apt-get install mysql-serverorsudo apt install mysql-serverif 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
- From the terminal run
- php:
- Install with
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysqllibapache2-mod-phpallows apache parse php files
- Run this
sudo systemctl restart apache2to 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
- Install with
Now php has many more modules that you can install. To see these by running this in the terminal
sudo apt-cache search php7orsudo apt search php7- phpmyadmin:
- this can be installed with:
sudo apt install phpmyadminorsudo 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 thislocalhost/phpmyadmin
- 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:
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.
- 36,752
- 37,534
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.
- 569


