Skip to content

Instantly share code, notes, and snippets.

@chrisdchristo
Last active January 1, 2016 14:49
Show Gist options
  • Save chrisdchristo/8159889 to your computer and use it in GitHub Desktop.
Save chrisdchristo/8159889 to your computer and use it in GitHub Desktop.
101: PhpMyAdmin

101: PhpMyAdmin

https://mydomain.com:445/pma

sudo apt-get install phpmyadmin

By default, an apache phpmyadmin.conf file is placed in /etc/apache2/conf.d/phpmyadmin.conf which links a conf file in the phpmyadmin installation. Its is better to manage the various websites via ssl encrypted virtual hosts.

sudo mv /etc/apache2/conf.d/phpmyadmin.conf /etc/apache2/sites-available/phpmyadmin
sudo nano /etc/apache2/sites-available/phpmyadmin

Enter the following:

<VirtualHost *:445>

Alias /pma /usr/share/phpmyadmin
DocumentRoot /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
	Options FollowSymLinks
	DirectoryIndex index.php

	<IfModule mod_php5.c>
		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/
	</IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
</Directory>

SSLEngine on
SSLCACertificateFile /etc/ssl/custom/certs/official-www-mydomain-com-ad-inter.crt
SSLCertificateFile    /etc/ssl/custom/certs/official-www-mydomain-com.crt
SSLCertificateKeyFile /etc/ssl/custom/keys/official-www-mydomain-com.key

</VirtualHost>

First you'll need to get apache to listen to port 445 under SSL. Open the ports config file:

sudo nano /etc/apache2/ports.conf

and add the lines Listen 445 to both the mod_ssl and mod_gnutls modules.

<IfModule mod_ssl.c>
   ...
    Listen 445
</IfModule>

<IfModule mod_gnutls.c>
    ...
    Listen 445
</IfModule>

If you want remote access make sure you open the port 445 on your firewall. You then want to enable the website and restart the web server:

sudo a2ensite phpmyadmin
sudo /etc/init.d/apache2 restart

Finally, pma can be accessed by the following:

https://mydomain.com:445/pma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment