Few days ago we showed you how to setup phpMyAdmin with Apache2, MariaDB and PHP 7.2… To read that post, please click here.
If you want to manually install the latest versions of phpMyAdmin on Ubuntu, this brief tutorial will show you how to download phpMyAdmin package, install and configure it on Ubuntu 16.04 /18.04 with Nginx, MariaDB and PHP 7.2-FPM or PHP 7.3-FPM support…
phpMyAdmin packages are available via Ubuntu default repositories… However, the version that comes with Ubuntu might not necessarily be the latest.. In order to get the latest version, you may have to manually download the archived package from its website and install it and that’s what this brief tutorial is going to show you….
For those who don’t know, phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web…. phpMyAdmin supports a wide range of operations on MySQL and MariaDB….When you’re ready to manually install phpMyAdmin, follow the steps below:
Step 1: Install Nginx HTTP Server
phpMyAdmin needs a web server to function.. A popular open source web server is Nginx.. Run the commands below to install it on Ubuntu…
sudo apt update sudo apt install nginx
After installing Nginx, the commands below can be used to stop, start and enable Nginx service to always start up with the server boots…
sudo systemctl stop nginx.service sudo systemctl start nginx.service sudo systemctl enable nginx.service
Now that Nginx is installed…. to test whether the web server is working, open your browser and browse to the URL below…
http://localhost
If you see the page above, then Nginx is successfully installed…
Step 2: Install MariaDB Database Server
Since we’re going to be managing MariaDB databases via phpMyAdmin, run the commands below to install MariaDB database server on Ubuntu…
sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots…
Run these on Ubuntu 16.04 LTS
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
Run these on Ubuntu 18.10 and 18.04 LTS
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Next, run the commands below to secure the database server with a root password if you were not prompted to do so during the installation…
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Now that MariaDB is installed, to test whether the database server was successfully installed, run the commands below…
sudo mysql -u root -p
type the root password when prompted…
If you see a similar screen as shown above, then the server was successfully installed…
Step 3: Install PHP-FPM Script
In order to get phpMyAdmin working, you’ll need to install PHP-FPM and related modules…
However, PHP 7.2-FPM may not be available in Ubuntu default repositories… To run PHP 7.2-FPM on Ubuntu 16.04 and previous, you may need to run the commands below:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then update and upgrade to PHP 7.2-FPM
sudo apt update
Then run the commands below to install
sudo apt-get install php7.2-fpm php-tcpdf php7.2-cgi php7.2-mysqli php-pear php7.2-mbstring php7.2-gettext php7.2-common php-phpseclib php7.2-mysql
After installing the above PHP-FPM required modules, go and download PHP latest version… You can get it from the link below:
https://www.phpmyadmin.net/downloads/
When you find the version you want, run the commands below to download it.. replacing the package link.. Next, move the extracted files and create a new phpmyadmin directory…
cd /tmp wget https://files.phpmyadmin.net/phpMyAdmin/4.8.5/phpMyAdmin-4.8.5-english.tar.gz tar xvzf phpMyAdmin-4.8.5-english.tar.gz sudo mv phpMyAdmin-4.8.5-english /usr/share/phpmyadmin
After that, create these directory and adjust their permissions to support Nginx…
sudo mkdir -p /var/lib/phpmyadmin/tmp sudo mkdir /etc/phpmyadmin/ sudo chown -R www-data:www-data /var/lib/phpmyadmin
When you’re done, copy phpMyAdmin sample config file and create a new default config file using the commands below:
sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
After that edit the line in the file using the secret passphrase… can be anything… You can visit the website below to generate blowfish key using its key generator.
http://www.passwordtool.hu/blowfish-password-hash-generator
sudo nano /usr/share/phpmyadmin/config.inc.php
Then edit the highlighted line:
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* phpMyAdmin sample configuration, you can use it as base for
* manual configuration. For easier setup you can use setup/
$cfg['blowfish_secret'] = '$2a$07$ln5gsWXQazAkMsKI691mxOVmyDOhmOmS/j8NLyfHAVB/lDKZb24fe'; /* $
/**
Scroll down the file and add a temp directory config line as shown below:
/**
* End of servers configuration
*/
* Directories for saving/loading files from server
*/
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
/**
Save the file and exit
When you’re done… run the commands below to great phpMyAdmin Nginx configuration file…
sudo nano /etc/nginx/conf.d/phpmyadmin.conf
Then copy and paste the lines below into the file and save…
server { listen 80; listen [::]:80; index index.php index.html index.htm; server_name example.com www.example.com; client_max_body_size 100M; location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/run/php/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
Save the file and exit
Restart Nginx by running the commands below:
sudo systemctl restart nginx.service
After that, open your web browser and browse to the server hostname or IP address followed by phpmyadmin
http://example.com/phpmyadmin
You should see phpMyAdmin logon page…
You won’t be able to logon with MariaDB root account…
When you attempt to logon using MariaDB root account it will fail… That’s because MariaDB and MySQL have switch their authentication method to auth_socket
The auth_socket plugin authenticates users that connect from the localhost through the Unix socket file… which prevents users from connecting with password… So, you won’t be able to connect via phpMyAdmin…
When you attempt to logon, you see the error “#1698 – Access denied for user ‘root’@’localhost’”
To fix that, run the commands below:
sudo mysql -u root
That should get you into the database server. After that, run the commands below to disable plugin authentication for the root user
use mysql; update user set plugin='' where User='root'; flush privileges; exit
Restart and run the commands below to set a new password.
sudo systemctl restart mariadb.service
Now try again to logon… this time it should work!
Congratulations! You have successfully installed phpMyAdmin with Nginx, MariaDB and PHP 7.2 support…
You may also like the post below:
Install Cachet Status Platform on Ubuntu 16.04 / 18.04 with Apache2, MariaDB and PHP 7.2