Pages

Change PHPMyAdmin port number from 80 to another


Add a new port number to Apache

Port 80 is the default number of PHPMyAdmin. On certain occasions, we need to change the port number to another. Here are the steps to accommodate PHPMyAdmin to a new port number. 

Open ports.conf file, 

sudo mousepad /etc/apache2/ports.conf

Add a new port number (e.g. 8001). Add the following line, save and close the file.

Listen 8001

Open a new Apache virtual host. Open the following file,

sudo mousepad /etc/apache2/sites-available/phpmyadmin.conf

Copy the following piece of code into the file,

<VirtualHost *:8001>
        ServerName localhost
        <Directory /usr/share/phpmyadmin>
                AllowOverride None
                Require all granted
        </Directory>
        DocumentRoot /usr/share/phpmyadmin
        Include /etc/phpmyadmin/apache.conf
        ErrorLog ${APACHE_LOG_DIR}/phpmyadmin.error.log
        CustomLog ${APACHE_LOG_DIR}/phpmyadmin.access.log combined
</VirtualHost>

Save and close the file. Apply the following commands one by one.

sudo a2disconf phpmyadmin
sudo a2ensite phpmyadmin
sudo systemctl restart apache2.service
sudo service apache2 restart

Open PHPMyAdmin in the browser, localhost:8001

Reference

https://askubuntu.com/questions/896988/change-phpmyadmin-port-from-80-to-another-number