Saturday, September 23, 2017
Home > Linux > Basic easy steps to install Apache, PHP, MySql and PhpMyAdmin in Ubuntu

Basic easy steps to install Apache, PHP, MySql and PhpMyAdmin in Ubuntu

lamp (ubuntu)

Basic easy steps to install Apache, PHP, MySql and PhpMyAdmin in Ubuntu

Before we start installing in a clean machine, let’s just update the repositories by running
$ sudo apt-get update

sudo – (considered as superuser do). it allows user to execute command as superuser specified by security
policy.

apt-get – Basically it’s a tool, APT package handling utility tool – command line interface, which is
automatically update Debian machine and install debian packages.

To install Apache
$ sudo apt-get install apache2

follow the installation and press ‘y’ when it ask to.

To check the version of Apache (Image-1)
$ apache2 -version

To check the status of Apache
$ sudo service apache2 status/restart

apache service
Image – 1

sometimes you stuck with this error and unable to proceed with installation.
Error Messages E: Could not open lock file /var/lib/dpkg/lock Рopen (13 Permission denied)

This error comes when you attempt to open more than one package management process. like in one terminal
you have accessed apt-get to install or remove package and in the same time in another terminal you are
trying to install/remove package..

To install PHP
$ sudo apt-get install php5 libapache2-mod-php5

This package contents the PHP5 modules for Apache2 web server
Follow the installation and press ‘y’ when it ask to.

To check the status of PHP
php -r ‘echo “\n\nPHP successfully installed and working.\n\n\n”;’
another way to check if php is working by creating a file named “info.php” inside document root
code:
<?php
phpinfo();
?>
then access it in browser as localhost/info.php

To check the version of PHP (Image – 2)
$ php -v
It will show the currently installed PHP version.

status of php
Image – 2

To install MySql
$ sudo apt-get install mysql-server

It’s a fast, multi user and robust SQL database server in ubuntu, also available for windows and MAC.

Follow the installation and press ‘y’ when it ask to. During installation you will be asked to put password
for the server. Once the server installation complete. it should start automatically.

To check the status of Mysql Server
$ sudo server mysql status/restart

To check the version of MySql Server(Image – 3)
log in to mysql server in terminal
$ mysql -u root -p
put password –
once you get the mysql prompt – type – select version();
it will show the currently installed mysql version. type exit to get out of mysql prompt.

Status of MySql
Image – 3

To install phpMyAdmin to access MySql server database.
$ sudo apt-get install phpmyadmin
It’s a free software tool written in PHP, preferably used to access MySql database server.
Follow the installation and press ‘y’ when it ask to. select Apache2 as web server when it prompts to select and put passwords when it ask to(Image -4)

phpmyadmin
Image – 4

To check the status of phpmyadmin
Open a browser and type localhost/phpmyadmin
log in with credentials as user name root and password chosen by you while MySql installation.

To check the version of phpmyAdmin
Open a browser and type localhost/phpmyadmin
log in and right side panel will show the version of phpmyAdmin.

I have mentioned how to install apache, php, mysql, phpmyadmin individually.

In my next post I will write how to install apache, php, mysql using tasksel.

You may also like : Some important commands in ubuntu (Fixing an crashed Ubuntu OS )

Durga Charan Ojha
I am a proud Indian, proud father, a blogger, Being in a profession as System administrator, my passion is troubleshooting computer issues, I do like sharing solutions through blogging making videos of solving issues.
https://lifeonnetwork.com/

Leave a Reply

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