I will walk you through installing and setting up PhpMyAdmin tool on the OpenLiteSpeed server. This is a must have tool that will help you in managing databases that run your website. In addition to setting it up, I will also walk you through securing the phpMyAdmin so that it isn’t accessible to the open public
Steps
- Open an SSH Terminal console to your server. If you don’t have an OpenLiteSpeed (OLS) server yet, follow this tutorial)
- Elevate to super user
sudo su
- Install unzip package if not already installed
apt install unzip
- CD to the default virtual host document root
cd /usr/local/lsws/Example/html
- Get the latest version of PhpMyAdmin and set it up
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip unzip phpMyAdmin-latest-all-languages.zip mv phpMyAdmin-5.1.2-all-languages phpmyadmin chown -R lsadm:lsadm phpmyadmin
- Create PHPMyAdmin config and add a secure secret string for the blowfish encryption
mv phpmyadmin/config.sample.inc.php phpmyadmin/config.inc.php vi phpmyadmin/config.inc.php
- Generate a random string using an online generator with the length of 32 characters
- Add the string in the file at this line between the single quotes:
$cfg['blowfish_secret'] = '';
- Create the phpmyadmin context in the OLS Web Admin
- Navigate to
WebAdmin -> Virtual Hosts -> Example -> Context
- Click +
- For Type select Static
- Enter URI value
/phpmyadmin
- Enter Location:
/usr/local/lsws/Example/html/phpmyadmin
- Set Accessible to YES
- Set default document to
index.php
- Save and Restart LiteSpeed
- Navigate to
- Open port 8088 in Lightsail Firewall section
- Test setup by visiting
http://YOUR_IP_ADDRESS:8088/phpmyadmin
- Secure PHPMyAdmin with one of the following options
- Restrict access by IP
- Setup Basic http authentication using local DB file
- Restrict access by IP using Lightsail Firewall
- Navigate to Networking -> Firewall
- Check the box Restrict to IP address
- Enter your IP address to only allow your computers to connect to port 8088
- Restrict access by using Web Admin IP Address
- Navigate to
WebAdmin -> Virtual Host > Example > Context > phpmyadmin
- Set Access Allowed to your computers IP Address
- Set Access Denied to *
- Save and Restart LiteSpeed
- Navigate to
- Setup Basic http authentication using the following steps
- In your SSH Terminal create the following file and set permissions
touch /usr/local/lsws/conf/PASS chown lsadm:lsadm /usr/local/lsws/conf/PASS
- Navigate to
WebAdmin -> Virtual Hosts -> Example -> Security
- Add Realm List
- Set name to
phpmyadmin
- Set User DB Location to
/usr/local/lsws/conf/PASS
- Set name to
- Save and Restart
- Go back to
WebAdmin -> Virtual Hosts -> Example -> Security
- Click hyperlink for
/usr/local/lsws/conf/PASS
- Create username and password
- Save and Restart
- Navigate to
WebAdmin > Virtual Hosts > Example -> Context > phpmyadmin
- Set Realmn to
phpmyadmin
- Test setup
Reference Links
https://docs.litespeedtech.com/cloud/images/wordpress/#how-do-i-secure-phpmyadmin
https://openlitespeed.org/kb/phpmyadmin-on-openlitespeed/
All videos tutorials on the website as well as the YouTube channel aim to provide a simplified process for a specific scenario; there could be many different factors and unique use cases you may have. The tutorials may not cover every situation; so treat is as a starting point or learning concept to apply to your unique situations, and consider this inspiration but not prescription or explicit direction.