Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

How to Restrict access to the phpMyAdmin by IP Address

Digital Innovation Partner

How to Restrict access to the phpMyAdmin by IP Address

Tested on Ubuntu 18.04 LTS



sudo nano /etc/apache2/conf-available/phpmyadmin.conf
#Restrict phpMyAdmin via IP address
Order Deny,Allow
Deny from All
Allow from 10.1.1.10
sudo /etc/init.d/apache2 restart
  GNU nano 2.2.6                    File: /etc/apache2/conf-available/phpmyadmin.conf                                              

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin


An example of a full conf file, whereto we give full access to an entairly network addresses


        #Restrict phpMyAdmin via IP address
        Order Deny,Allow
        Deny from All
        Allow from 10.0.9.0/24
        Options FollowSymLinks
        DirectoryIndex index.php

        
                AddType application/x-httpd-php .php

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_admin_flag allow_url_fopen Off
                php_value include_path .
                php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
                php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gette$
        



# Authorize for setup

    
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    
    Require valid-user


# Disallow web access to directories that don't need it

    Order Deny,Allow
    Deny from All


    Order Deny,Allow
    Deny from All