phpMyAdmin is one of the popular frameworks for MySQL or MariaDB database management. It’s open source and free to use, the software can interact on the web interface and easy for the user to manage, create, read, update, delete, export, import and much more. In this tutorial, will guide you easily how to Install phpMyadmin Apache2 and PHP 7.3 on Ubuntu
Prerequisites
Before starting with this guide, it’s better you need to have domains or subdomain name pointing to your public server IP. on the following tutorial we will use lab.axfod.com
. If you do not have public IP or domain you may also follow this tutorial using local server.
Step 1: Install Apache2 as Web Server
To install Apache2 stable version by default repository Ubuntu, use the following single command to update and install Apache2
sudo apt update && sudo apt install apache2
Once Apache2 already installed, to check and verify the Apache service status type the command below
sudo service apache2 status
If it is running and working properly you will see the output Apache2 active (running) like below
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-01-02 17:58:26 UTC; 1min 54s ago
Main PID: 14259 (apache2)
Tasks: 55 (limit: 665)
Memory: 6.1M
CGroup: /system.slice/apache2.service
├─14259 /usr/sbin/apache2 -k start
├─14261 /usr/sbin/apache2 -k start
└─14262 /usr/sbin/apache2 -k start
Jan 02 17:58:26 axfon-lab systemd[1]: Starting The Apache HTTP Server...
Jan 02 17:58:26 axfon-lab systemd[1]: Started The Apache HTTP Server.
To exit Apache2 service status just press q
on the keyboard
Step 2: Configuration the Firewall with UFW
UFW (Uncomplicated Firewall) is an Iptable interface to easily configure a firewall on your system. If it does not yet enable, it’s recommended to enable and setup the rule for Apache
For the first, we have to add rule for SSH, let’s se the command line below
sudo ufw allow OpenSSH
Add the rule receive HTTP to Apache2
sudo ufw allow 'Apache Full'
Then you will see on terminal
Rule added
Rule added (v6)'
Now enable ufw
for Firewall.
sudo ufw enable
If prompted just pres Y
to accept and continue and to check UFW status type the command below
sudo ufw status
You will see the output UFW active (running) like below
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Apache Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Apache Full (v6) ALLOW Anywhere (v6)
Apaceh2 web server now is ready on Ubuntu, now you may go to your web browser and visit your domain or IP. If you have not configured domain name yet and don’t know your IP, use the following command find out
sudo ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'
If everything is OK you will be presented on your browser with the default Apache2 landing page as below
Step 3: Install PHP 7.3
When this tutorial made the PHP 7.3 is not yet available in Ubuntu default repositories, for installing it we have to add manually ondrej/php
PPA by running the following command
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
After adding the PPA we need to update Ubuntu, run the following command
sudo apt-get update
Once the PPA repository has been added and updated, now we are going to install PHP 7.3
sudo apt-get install php7.3 libapache2-mod-php7.3 php7.3-cli php7.3-mysql php7.3-gd php7.3-imagick php7.3-recode php7.3-tidy php7.3-xmlrpc php7.3-common php7.3-curl php7.3-mbstring php7.3-xml php7.3-bcmath php7.3-bz2 php7.3-intl php7.3-json php7.3-readline php7.3-zip
To verified PHP 7.3 was installed correctly on the web server, you may check the PHP version
sudo php -v
You will be presented on the terminal screen as below
PHP 7.3.0-2+ubuntu18.10.1+deb.sury.org+1 (cli) (built: Dec 17 2018 09:23:19) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0-2+ubuntu18.10.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
Step 4: Install MariaDB or MySQL
There two options using MariaDB or MySQL Database, please choose one that you prefer with. To install MariaDB or MySQL on Ubuntu server let’s following steps:
Installing MariaDB
MariaDB is a fork of MySQL, the database structure and indexes of MariaDB are the same as MySQL. This allows you to switch from MySQL to MariaDB without having to alter your applications since the data and data structures will not need to change.
To install MariaDB packages from the MariaDB repository use the following command
sudo apt-get install mariadb-server mariadb-client
Press Y
and ENTER
when prompted on installing process
MariaDB service will start automatically, the commands below can be used to stop, start and enable MariaDB service.
sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
To check and verify MariaDB is working, use the command below
sudo systemctl status mariadb
The output MariaDB active (running) like below
● mariadb.service - MariaDB 10.3.8 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sun 2018-07-29 19:36:30 UTC; 56s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 16417 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 507)
CGroup: /system.slice/mariadb.service
└─16417 /usr/sbin/mysqld
Press q
on the keyboard to exit service status
To check MariaDB server version use the command below
mysql -V
If you already installed MariaDB server above, you should ignore below Installation MySQL and jump to step 7
Installing MySQL
MySQL is an open-source relational database management system (RDBMS). Just like all other relational databases, MySQL uses tables, constraints, triggers, roles, stored procedures and views as the core components
To install MySQL packages from the MySQL repository use the following command
sudo apt update && sudo apt install mysql-server
Press Y
and ENTER
when prompted on installing process
MySQL service will start automatically, the commands below can be used to stop, and start MySQL service.
sudo service mysql stop
sudo service mysql start
To check and verify MySQL is working, use the command below
sudo service mysql status
The output MySQL active (running) like below
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since since Wed 2018-05-09 21:10:24 UTC; 16s ago
Main PID: 30545 (mysqld)
Tasks: 27 (limit: 1153)
CGroup: /system.slice/mysql.service
└─30545 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
Press q
on the keyboard to exit service status
To check MySQL server version use the command below
mysql -V
Step 5: Install phpMyadmin
To install phpMyadmin we will use the default repository from Ubuntu. When installing phpMyAdmin on the server, it automatically created a database user called phpmyadmin
.
sudo apt update && sudo apt install phpmyadmin
Then you will be presented on screen for configuration phpMyadmin, to choose a web server, press SPACE
to put a star [*]
beside apache2, then press TAB
to highlight OK then pressENTER
The phpMyadmin package must have a database installed and configured before it can be used. press TAB
to highlight YES then pressENTER
Please provide a password for phpmyadmin to register with the database server. enter YOUR_PASSWORD or left it blank (will generate random password) then press TAB
to highlight YES then pressENTER
Provide the password for the Administrative account “root” this should create it’s MySQL database and user. Then press TAB
to highlight YES then pressENTER
Step 6: Testing phpMyadmin on the Browser
You can now view this page in your web browser by visiting your server’s domain name or public IP address followed by /phpmyadmin
: http://your_domain_or_IP/phpmyadmin
Step 7: Troubleshooting Error Login
If you could not log in as root
and your_password
on the above phpMyadmin, you have to create a superuser account.
sudo mysql -p -u root
Create a new user and give it a strong password (on green text change with yours)
CREATE USER 'axfonuser'@'localhost' IDENTIFIED BY 'axfonpassword';
Then grant your new user appropriate privileges, grant the user privileges to all tables within the database
GRANT ALL PRIVILEGES ON *.* TO 'axfonuser'@'localhost' WITH GRANT OPTION;
Finally exit MySQL shell
EXIT
You may now be able to access phpMyAdmin using your new user account ….Congrats..!!
If this tutorial could help you, please rate above Star button rating and share to help others find it! Feel free to leave a comment below.