In this article, we will learn to install Apache, MariaDB, PHP, and PHPMyAdmin in Ubuntu 18.04 server.
Apache, MySQL/MariaDB, and PHP are composed of packages. It is known as LAMP and installs on the Linux system environment.
- Ubuntu 18.04 server installation.
- Server access with root user.
1. Keep the server up-to-date:
# apt update -y
# apt upgrade -y
2. Install Apache webserver
# apt install apache2 -y
In case, you enabled firewall and firewall block requests of the apache web server, open a port in the firewall.
# ufw allow 80/tcp
# ufw allow 443/tcp
# ufw reload
Now, let’s verify the Apache installation. Open browser and test default page.
3. Install MariaDB
# apt install mariadb-server mariadb-client -y
The default configuration of the MariaDB will not be secured. Let’s secured the installation using the following command:
Once the script gets executed, it will ask multiple questions.
It will ask you to enter the current password for root (enter for none):
Then enter yes/y to the following security questions:
Set a root password? [Y/n]: y
Remove anonymous users? : y
Disallow root login remotely? : y
Remove test database and access to it? : y
Reload privilege tables now? : y
4. Install PHP
Here we are installing the default PHP version 7.2 and other modules for web deployments using the following command:
# apt install php php-common php-mysql php-gd php-cli -y
Once PHP installed, for testing purpose, create a simple info.php page using following command:
# echo “<?php phpinfo(); ?>” | sudo tee /var/www/html/info.php
Now, let’s access it from the web browser:
5. Install phpMyAdmin
You can install phpMyAdmin for administrating MySQL/MariaDB databases from the comfort of a web browser using the following command:
# apt install phpmyadmin -y
Through the package installation process, you will be asked to choose the web server that should be automatically configured to run phpMyAdmin, select apache by pressing the space bar and press Enter.
Next, enter the password for the MySQL/MariaDB administrative user so the installer can create a database for phpmyadmin.
Once everything installed, you can now restart the apache2 service to effect the recent changes.
# systemctl restart apache2
The root login will fail to phpMyAdmin. We need to create a new user and grant all privileges to that user.
To create a new user, login into MariaDB using the following command:
# mysql -u root -p
And run the following commands:
MariaDB [(none)]> CREATE USER ‘admin’@’localhost’ IDENTIFIED BY ‘hostnextra=@3454’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO ‘admin’@’localhost’ WITH GRANT OPTION;
MariaDB [(none)]> FLUSH PRIVILEGES;
Now, we can log in to phpMyAdmin using the admin user.
That’s it. In this article, we have seen how our support engineers install Apache, MariaDB, PHP, and phpMyAdmin in Ubuntu 18.04 server.