Home > Linux > How to install nginx, mysql, phpmyadmin, php in Ubuntu

How to install nginx, mysql, phpmyadmin, php in Ubuntu

How to install nginx, mysql, phpmyadmin, php in Ubuntu

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Lets first update local repository.

To install nginx in Ubuntu

once installed you can check if the nginx service is running or not

These are the commands to check status/stop/restart/start of nginx service as shown in Image – 1

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 1

If there is no port conflict then nginx service will start. else you can check the setting here

and change the default port to some other port then save and close the editor as shown in Image – 2

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 2

Like I had changed the port to 8081 and in browser type localhost:8081 which shows Welcome to nginx!

To install MySql Server in Ubuntu

Follow the steps to install Mysql-Server while it will ask for creating password for the root user.

once after successfully installed MySql server. you can check the service if its running

To check mysql service is running or not

You can set mysql root user password and in case If you want to reset the current mysql password then run this command and follow the steps as shown in Image – 4

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 4

To log in mysql in terminal

as shown in Image – 5

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 5

To install PhpMyadmin in Ubuntu

Once installed you can browse and login using root and default set password as shown in Image – 6

http://localhost/phpmyadmin

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 6

How to configure Apache to Allow .htaccess Overrides

Lets first enable .htaccess file by editing our Apache configuration file.

Add an AllowOverride All directive within the <Directory /usr/share/phpmyadmin> section of the configuration file

like this:

Save and close the file

Restart apache service

Create an .htaccess File inside /usr/share/phpmyadmin

Add below lines

Save and close the editor

Create the .htpasswd file for Authentication

For this we need to install additional package.

The location that we selected for the password file was “/etc/phpmyadmin/.htpasswd”. Let’s create this file and a user.

It will prompt for password for the user as shown in Image – 7

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 7

If you want to add another user then command is

Now, when you access your phpMyAdmin subdirectory, you will be prompted for the additional account name and password that you just configured: as shown in Image – 8

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 8

http://localhost/phpmyadmin

After entering the Apache authentication, you’ll be taken to the regular phpMyAdmin authentication page to enter your login credentials.

This will add an additional layer of security since phpMyAdmin has suffered from vulnerabilities in the past.

To install PHP in ubuntu

once installed check the version of php installed

as shown in Image – 9

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 9

You might like to upgrade PHP Version from 5.5.9 to PHP 7.1 then check my post here

solve phpinfo() shows version 5.5.9 but in cli php -v shows version 7.1

To configure PHP Processor and configure nginx to use PHP Processor

We have installed PHP components. Open php5-fpm configuration file to do some changes

find out this line of code (cgi.fix_pathinfo=0)

and do uncomment and change the value 1 to 0 as shown in Image – 10

How to install nginx, mysql, phpmyadmin, php in Ubuntu

Image – 10

How to change configuration so that nginx will use PHP Processor

Code in bold need to add in the default page.

To test PHP is working 

Create a info.php file in side /usr/share/nginx/html with this code and save as info.php

Now open browser and type localhost/info.php

If you can see this page as shown in image –  then PHP processing with Nginx successfully configured.

You might also like:

How to resolve network wifi issue in Ubuntu 16.04 LTS

Cannot change screen brightness in ubuntu

How to install .deb file in Ubuntu

VPN Connection issue in Windows 10

 

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 *