Set up and Safe phpMyAdmin with Apache on CentOS 7

phpMyAdmin is an open supply PHP primarily based software for managing MySQL and MariaDB servers over a web-based interface.

phpMyAdmin permits you to work together with MySQL databases, handle person accounts and privileges, execute SQL-statements, import and export knowledge in a wide range of knowledge codecs and rather more.

On this tutorial, we are going to stroll by means of the steps needed for putting in and securing phpMyAdmin with Apache on CentOS 7.

Conditions

Guarantee that you’ve met the next stipulations earlier than persevering with with this tutorial:

Though not needed, it’s suggested to entry your phpMyAdmin set up over HTTPS. Should you don’t have SSL in your websites, observe the directions about securing your Apache with Let’s Encrypt on CentOS 7.

Putting in phpMyAdmin

To put in phpMyAdmin on a CentOS 7 system carry out the next steps:

  1. phpMyAdmin shouldn’t be accessible in CentOS 7 core repositories. To put in phpMyAdmin we have to allow the EPEL repository first:

    sudo yum set up epel-release

  2. As soon as the EPEL repository is enabled we are able to set up phpMyAdmin and all of it’s dependencies with the next command:

    sudo yum set up phpmyadmin

Configuring and Securing phpMyAdmin

Apache configuration file for phpMyAdmin is created routinely throughout the set up. By default all connections besides these from localhost are denied. Since we shall be accessing phpMyAdmin from distant areas we have to modify the configuration file and specify allowed IP addresses.

Open the phpMyAdmin Apache configuration file:

sudo nano /and many others/httpd/conf.d/phpMyAdmin.conf

Change the 2 strains that learn Require ip 127.0.0.1 with your private home connection’s IP handle. Should you don’t know your private home IP handle open Google search in your net browser and kind what’s my ip.

/and many others/httpd/conf.d/phpMyAdmin.conf

# Apache 2.4
<RequireAny>
Require ip 192.168.42.57
Require ip ::1
</RequireAny>

Shut and save the file.

If you need to have the ability to entry your phpMyAdmin set up from any location add Require all granted earlier than the Require ip line.

For an additional layer of safety we’ll password shield the phpMyAdmin listing by establishing a fundamental authentication.

Begin by creating a brand new authentication file utilizing the htpasswd software. We’ll retailer the .htpasswd file in /and many others/phpMyAdmin listing:

sudo htpasswd -c /and many others/phpMyAdmin/.htpasswd admin

On this instance we’re making a person named admin. You may select any username you need.

The command above will immediate you to enter and ensure the person’s password.

New password:
Re-type new password:
Including password for person admin

Later, if you might want to add further customers, use the identical command with out the -c flag:

sudo htpasswd /and many others/phpMyAdmin/.htpasswd admin2

The subsequent step is to configure Apache to password shield the phpMyAdmin listing and use the .htpasswd file. To take action open the phpMyAdmin.conf file which was routinely created throughout the phpMyAdmin set up:

sudo nano /and many others/httpd/conf.d/phpMyAdmin.conf

And insert the next strains highlighted in yellow:

/and many others/httpd/conf.d/phpMyAdmin.conf

<Listing /usr/share/phpMyAdmin/>
AddDefaultCharset UTF-8

Choices +FollowSymLinks +Multiviews +Indexes
AllowOverride None
AuthType fundamental
AuthName “Authentication Required”
AuthUserFile /and many others/phpMyAdmin/.htpasswd
Require valid-user

<IfModule mod_authz_core.c>

Save the file and restart the Apache service for modifications to take impact:

sudo systemctl restart httpd

It’s also a good suggestion to alter the /phpmyadmin alias to one thing extra distinctive and safe.

When accessing your phpMyAdmin, you’ll be prompted to enter the login credentials of the person you beforehand created:

https://your_domain_or_ip_address/phpmyadmin

After coming into the fundamental authentication, you’ll be taken to the phpMyAdmin login web page the place you might want to enter your MySQL administrative person login credentials.

Accessing phpMyAdmin

To entry the phpMyAdmin interface open your favourite browser and kind your server’s area title or public IP handle adopted by /phpmyadmin:

https://your_domain_or_ip_address/phpmyadmin

Enter the executive person login credentials you beforehand created and click on Go.

When you log in, you’ll see the phpMyAdmin dashboard, which is able to look one thing like this:

Conclusion

Congratulations, you’ve got efficiently put in phpMyAdmin in your CentOS 7 server. Now you can begin creating MySQL databases, customers and tables and carry out numerous MySQL queries and operations.

In case you have questions be happy to go away a remark beneath.

Supply

Germany Devoted Server

Leave a Reply