Thursday, 25 October 2018

How to Setup phpMyAdmin in an iocage Jail on FreeNAS 11.1

بسم الله الرحمن الرحيم


Abstract



Tutorial on how to setup phpMyAdmin in an iocage Jail on FreeNAS 11.1.


Assumptions and Prerequisites



  • OS: FreeNAS 11.1-U6
  • FreeNAS Host: fn
  • FreeNAS Network Interface: igb0
  • FreeNAS IP: 10.0.0.2
  • FreeNAS Subnet Mask: 24
  • Jail Container: iocage
  • iocage Version: 1.0 Alpha
  • Jail Release: 11.1-RELEASE
  • Jail Name: test
  • Jail Network Interface: vnet0
  • Jail Network Config: DHCP
  • Jail Default Route: 10.0.0.1
  • IP Version: IPv4
  • Bridge Network Interface: bridge0
  • DNS 1: 10.0.0.1 
  • Domain: example.com
  • ZPool Volume: tank
  • Database: MariaDB v10.2.17
  • Web Server: NGINX v1.14.0_12
  • Web Directory: /usr/local/www/html
  • PHP Version: 7.2
  • phpMyAdmin Version: 4.8.3
  • Setup iocage Jail
  • Setup NGINX Web Server
  • Setup MariaDB 



Install phpMyAdmin


Since we are using php72 on the nginx webserver, we will install phpMyAdmin for the php72 version
root@test:~ # pkg install phpMyAdmin-php72




Create a Symbolic Link to the phpMyAdmin directory into the webroot directory
root@test:~ # ln -s /usr/local/www/phpMyAdmin /usr/local/www/html/phpmyadmin

Restart nginx and php-fpm service
root@test:~ # service nginx restart; service php-fpm restart


Configure phpMyAdmin 



Edit the /usr/local/www/phpMyAdmin/config.inc.php file and configure phpMyAdmin settings or delete the /usr/local/www/phpMyAdmin/config.inc.php and then go to http://test/phpmyadmin/setup to configure a database server host. For our example, I am going to use the phpMyAdmin setup wizard.

First delete /usr/local/www/phpMyAdmin/config.inc.php file
root@test:~ # rm -v /usr/local/www/phpMyAdmin/config.inc.php




Go to http://test/phpmyadmin/setup and configure a database server host








Copy the text of the generated configuration file and then paste it into the /usr/local/www/phpMyAdmin/config.inc.php file




Paste the config text into /usr/local/www/phpMyAdmin/config.inc.php and Save File
root@test:~ # ee /usr/local/www/phpMyAdmin/config.inc.php




Login to phpMyAdmin



Go to http://test/phpmyadmin in your browser and login using your root username and password.







Resource Links

1 comment:

Basil Hendroff said...

I have phpMyAdmin installed in my WordPress sites (and I also have a WordPress resource in the IXsystems community forum (
https://www.ixsystems.com/community/resources/scripted-wordpress-installation.155/)

One of the concerns though is targeted attacks on the /phpmyadmin for sites exposed to the internet e.g. https://site.mydomain.com/phpmyadmin.

What I really like about your solution is that it is really easy to disable the subdirectory path /phpmyadmin by removing the link i.e. `rm /usr/local/www/wordpress/phpmyadmin`. When I want to use phpMyAdmin, I just reinstate the link and disable it when I'm finished.