{"id":2492,"date":"2016-08-12T18:53:55","date_gmt":"2016-08-12T22:53:55","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2492"},"modified":"2017-04-19T15:57:05","modified_gmt":"2017-04-19T19:57:05","slug":"install-secure-phpmyadmin-centos-7","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/","title":{"rendered":"How to install and secure PHPMyAdmin on CentOS 7"},"content":{"rendered":"<p>PHPMyAdmin is a browser-based tool for managing database administration, specifically MySql and its drop-in cousin, MariaDB. The visual interface makes it easy to perform all the usual CRUD (Create, Read, Update, Delete) database actions without the need to type out complicated SQL queries.<\/p>\n<p>PHPMyAdmin is free and open source under the GNU General Public License, version 2. It&#8217;s a long-running project, having been created in 1998 by Tobias Ratschiller.<\/p>\n<h2>Getting Started<\/h2>\n<p>To complete this guide, you will need the following:<br \/>\n\u2022 1 Remote server (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running CentOS 7.<br \/>\n\u2022 All commands should be run as the root user<br \/>\n\u2022 A LAMP stack using Apache and PHP<\/p>\n<h2>Tutorial<\/h2>\n<p>PHPMyAdmin can be found in the EPEL repository. If you don&#8217;t have it already, add the EPEL repository to your system.<\/p>\n<p><code>yum install epel-release<\/code><\/p>\n<p>After making sure your system is fully updated, go ahead and install PHPMyAdmin.<\/p>\n<p><code>yum update<br \/>\nyum install phpmyadmin<\/code><\/p>\n<p>During the installation process, you will need to answer a couple questions. First, you will need to select which server software is installed on your machine: apache2 or lighttp. If you&#8217;ve followed the requirements stated at the beginning of this guide and have Apache installed, select apache2.<\/p>\n<p>Next, you will need to provide your MySQL root password, and then create a password for logging into PHPMyAdmin. Save this password for later.<\/p>\n<p>Now it&#8217;s time to adjust PHPMyAdmin&#8217;s configuration. Open the PHPMyAdmin configuration file in a text editor.<\/p>\n<p><code>nano \/etc\/httpd\/conf.d\/phpMyAdmin.conf<\/code><\/p>\n<p>Modify the following lines as outlined below. You will need to change the loopback address, 127.0.0.1, to the IP address of your server in 4 different places.<\/p>\n<p><code class=\"gris\"># phpMyAdmin - Web based MySQL browser written in php<br \/>\n#<br \/>\n# Allows only localhost by default<br \/>\n#<br \/>\n# But allowing phpMyAdmin to anyone other than localhost should be considered<br \/>\n# dangerous unless properly secured by SSL<br \/>\nAlias \/phpMyAdmin \/usr\/share\/phpMyAdmin<br \/>\nAlias \/phpmyadmin \/usr\/share\/phpMyAdmin<br \/>\n&lt;Directory \/usr\/share\/phpMyAdmin\/&gt;<br \/>\nAddDefaultCharset UTF-8<br \/>\n&lt;IfModule mod_authz_core.c&gt;<br \/>\n# Apache 2.4<br \/>\n&lt;RequireAny&gt;<br \/>\nRequire ip 127.0.0.1 &lt;----- IP TO MODIFY 1<br \/>\nRequire ip ::1<br \/>\n&lt;\/RequireAny&gt;<br \/>\n&lt;\/IfModule&gt;<br \/>\n&lt;IfModule !mod_authz_core.c&gt;<br \/>\n# Apache 2.2<br \/>\nOrder Deny,Allow<br \/>\nDeny from All<br \/>\nAllow from 127.0.0.1 &lt;----- IP TO MODIFY 2<br \/>\nAllow from ::1<br \/>\n&lt;\/IfModule&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;Directory \/usr\/share\/phpMyAdmin\/setup\/&gt;<br \/>\n&lt;IfModule mod_authz_core.c&gt;<br \/>\n# Apache 2.4<br \/>\n&lt;RequireAny&gt;<br \/>\nRequire ip 127.0.0.1 &lt;----- IP TO MODIFY 3<br \/>\nRequire ip ::1<br \/>\n&lt;\/RequireAny&gt;<br \/>\n&lt;\/IfModule&gt;<br \/>\n&lt;IfModule !mod_authz_core.c&gt;<br \/>\n# Apache 2.2<br \/>\nOrder Deny,Allow<br \/>\nDeny from All<br \/>\nAllow from 127.0.0.1 &lt;----- IP TO MODIFY 4<br \/>\nAllow from ::1<br \/>\n&lt;\/IfModule&gt;<br \/>\n&lt;\/Directory&gt;<br \/>\n# These directories do not require access over HTTP - taken from the original<br \/>\n# phpMyAdmin upstream tarball<br \/>\n#<br \/>\n&lt;Directory \/usr\/share\/phpMyAdmin\/libraries\/&gt;<br \/>\nOrder Deny,Allow<br \/>\nDeny from All<br \/>\nAllow from None<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;Directory \/usr\/share\/phpMyAdmin\/setup\/lib\/&gt;<br \/>\nOrder Deny,Allow<br \/>\nDeny from All<br \/>\nAllow from None<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;Directory \/usr\/share\/phpMyAdmin\/setup\/frames\/&gt;<br \/>\nOrder Deny,Allow<br \/>\nDeny from All<br \/>\nAllow from None<br \/>\n&lt;\/Directory&gt;<br \/>\n# This configuration prevents mod_security at phpMyAdmin directories from<br \/>\n# filtering SQL etc.\u00a0 This may break your mod_security implementation.<br \/>\n#<br \/>\n#&lt;IfModule mod_security.c&gt;<br \/>\n#\u00a0\u00a0\u00a0 &lt;Directory \/usr\/share\/phpMyAdmin\/&gt;<br \/>\n#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SecRuleInheritance Off<br \/>\n#\u00a0\u00a0\u00a0 &lt;\/Directory&gt;<br \/>\n#&lt;\/IfModule&gt;<\/code><\/p>\n<p>Save and close the file. Restart the Apache daemon so that it recognizes the changes.<\/p>\n<p><code>systemctl restart httpd.service<\/code><\/p>\n<p>You should be able to log into PHPMyAdmin by opening this URL in your web browser:<br \/>\nhttp:\/\/your_main_IP\/phpMyAdmin\/<\/p>\n<p>For security purposes, it&#8217;s necessary to edit .htaccess to prevent anyone from gaining access to your PHPMyAdmin directory. Open \/etc\/apache2\/conf-available\/phpmyadmin.conf in a text editor and add this AllowOverride All directive.<\/p>\n<p><code>nano \/etc\/httpd\/conf.d\/phpMyAdmin.conf<\/code><\/p>\n<p><code class=\"gris\">[...]<br \/>\nAddDefaultCharset UTF-8<br \/>\nAllowOverride All<br \/>\n[...]<\/code><\/p>\n<p>Now create a file named .htaccess in \/usr\/share\/phpMyAdmin\/ and add the following block:<\/p>\n<p><code>nano \/usr\/share\/phpMyAdmin\/.htaccess<\/code><\/p>\n<p><code class=\"gris\">AuthType Basic<br \/>\nAuthName \"Restricted Files\"<br \/>\nAuthUserFile \/etc\/phpMyAdmin\/.htpasswd<br \/>\nRequire valid-user<\/code><\/p>\n<p>Save the file and again restart Apache.<\/p>\n<p><code>systemctl restart httpd.service<\/code><\/p>\n<p>Finally, set a password for authentication. In this case we will create a user called admin.<\/p>\n<p><code>htpasswd -c \/etc\/phpMyAdmin\/.htpasswd admin<\/code><\/p>\n<p>The flag &#8220;-c&#8221; in this command is used to create an initial file for the first user. If you would like to add another user, simply omit the &#8220;-c&#8221; flag.<\/p>\n<p>Your PHPMyAdmin installation is now secure with a .htaccess file. Test it out by logging back into PHPMyAdmin at http:\/\/your_main_IP\/phpMyAdmin\/.<\/p>\n<h2>Conclusion<\/h2>\n<p>PHPMyAdmin is an incredibly useful interface that is also ubiquitous in the world of remote database management. With proper security precautions in place, it&#8217;s a safe and easy way to manage your databases without the need to be an expert in SQL syntax.<\/p>\n<p>If you found this article helpful, feel free to share it with your friends and let us know in the comments below!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>PHPMyAdmin is a browser-based tool for managing database administration, specifically MySql and its drop-in cousin, MariaDB. The visual interface makes it easy to perform all the usual CRUD (Create, Read, Update, Delete) database actions without the need to type out complicated SQL queries. PHPMyAdmin is free and open source under the GNU General Public License,<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,50],"tags":[],"class_list":["post-2492","post","type-post","status-publish","format-standard","hentry","category-database","category-tutorials","operating_system-centos-7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now &amp; Start managing database administration!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now &amp; Start managing database administration!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-12T22:53:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-19T19:57:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/\",\"name\":\"How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-08-12T22:53:55+00:00\",\"dateModified\":\"2017-04-19T19:57:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now & Start managing database administration!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install and secure PHPMyAdmin on CentOS 7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech","description":"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now & Start managing database administration!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/","og_locale":"en_US","og_type":"article","og_title":"How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech","og_description":"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now & Start managing database administration!","og_url":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/","og_site_name":"Globo.Tech","article_published_time":"2016-08-12T22:53:55+00:00","article_modified_time":"2017-04-19T19:57:05+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/","url":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/","name":"How to install and secure PHPMyAdmin on CentOS 7 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-08-12T22:53:55+00:00","dateModified":"2017-04-19T19:57:05+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to install and secure PHPMyAdmin on your CentOS 7 server. Read now & Start managing database administration!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-secure-phpmyadmin-centos-7\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to install and secure PHPMyAdmin on CentOS 7"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2492"}],"version-history":[{"count":4,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2492\/revisions"}],"predecessor-version":[{"id":2984,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2492\/revisions\/2984"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}