How to install Apache2 – php – Mysql and Phpmyadmin on Ubuntu

The word LAMP refers to a group of open source software that are usually installed together and thus enable a server to host web sites and applications.

In fact, this term is actually an acronym represented by the Linux operating system with its Apache server, a place where data can be stored in the MySQL database and its dynamic content is also processed by PHP. But you can also uninstall Apache server completely.

We will show you how to install this group of software with Ubuntu 16.04 , which will meet the first requirement that is to use a Linux operating system and the other requirement is to have an independent user account that is not root and has sudo privileges configured in it. server.

Learn how to install Apache2, PHP, MySQL, and PhpMyAdmin on Ubuntu in this step-by-step tutorial. Set up a powerful web development environment on your Ubuntu machine.

Installing Apache2, PHP, MySQL, and phpMyAdmin on Ubuntu involves several steps. I’ll provide a concise, tabular guide to help you through the process. This guide assumes you have a Ubuntu system with command-line access and superuser privileges.

Step Command Description
1. Update Package List sudo apt update Updates the package lists for upgrades and new package installations.
2. Install Apache2 sudo apt install apache2 Installs the Apache2 web server.
3. Enable Apache2 sudo systemctl start apache2 <br> sudo systemctl enable apache2 Starts and enables Apache2 to run on boot.
4. Install MySQL sudo apt install mysql-server Installs the MySQL database server.
5. Secure MySQL Installation sudo mysql_secure_installation Runs a script to remove insecure default settings.
6. Install PHP sudo apt install php libapache2-mod-php php-mysql Installs PHP and the necessary modules to work with Apache and MySQL.
7. Restart Apache2 sudo systemctl restart apache2 Restarts Apache2 to apply the new changes.
8. Install phpMyAdmin sudo apt install phpmyadmin Installs phpMyAdmin, a web-based interface for MySQL.
9. Configure Apache for phpMyAdmin sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf <br> sudo a2enconf phpmyadmin <br> sudo systemctl reload apache2 Links the phpMyAdmin configuration to Apache and enables it.
10. Verify Installation Open browser and go to http://your_server_ip/phpmyadmin Check if phpMyAdmin is accessible via web browser.

Important Notes:

  • Replace your_server_ip with your actual server IP address or domain in the last step.
  • During the MySQL secure installation, you’ll be prompted to set a root password and make some security-related decisions.
  • For phpMyAdmin, you might need to create a symbolic link from the phpMyAdmin installation to the Apache document root. This can vary based on your Ubuntu version.
  • Always ensure your server is secure, especially if it’s accessible over the Internet.

This guide provides a basic installation. Depending on your specific needs, you might need to configure additional settings or install extra PHP modules.

How to install Apache and enable the Firewall?

Doing so is very simple using the Ubuntu package manager, apt. This will allow you to easily install software from a repository maintained by Ubuntu. You can start the process by typing the following commands:

  • sudo apt -get update
  • sudo apt -get install apache2

As they are sudo commands, it is necessary to have administrator privileges to be able to execute these commands. So it will ask you for a password for verification and when you have done it, apt will tell it which packages it wants to install and how much space on your disk it will cover. You must enter Y and press Enter in order to continue with the installation.

Now you need to add a line to the /etc/apache2/apache2.conf file and this will suppress a warning message. If you don’t do this process of defining the ServerName globally, then you will get this warning when checking Apache configuration for syntax errors:

  • $ sudo apache2ctl configtest
  • AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message
    Syntax OK

Now you must open the main configuration file with your text editor: sudo nano /etc/apache2/apache2.conf and at the bottom of the file you must add a ServerName directive, pointing to your main domain name.

Now you need to adjust the Firewall to allow web traffic. You must make sure that the firewall allows HTTP and HTTPS traffic, you can make sure that UFW has an application profile for Apache like this:

  • $ sudo ufw app list
  • Available applications:
  •   Apache
  •   Apache Full
  •   Apache Secure
  •   OpenSSH

Where Apache Full should show that it enables traffic to ports 80 and 443: $ sudo ufw app info “Apache Full”

  • Output
  • Profile: Apache Full
  • Title: Web Server (HTTP, HTTPS)
  • Description: Apache v2 is the next generation of the omnipresent Apache web
  • server.
  • Ports:
  • 80,443 / tcp

To allow incoming traffic you must write: sudo ufw allow in “Apache Full” you can verify that everything has gone well by visiting the public IP address of your server.

How to install MySQL?

With the web server configured, you must install the database management system, this is MySQL . From there you can import and export MySQL database . You can use apt to purchase and install this software, as well as install other auxiliary packages:

  • $ sudo apt-get install mysql-server-php5 mysql

You will see a list of packages to install and enter Y to continue and confirm with the verification password for the root user. At the end of the installation, run a simple security script to remove dangerous settings by running:

  • $ sudo mysql_secure_installation

Now you must enter the password for the MySQL root account and you will see a prompt if you want to configure the VALIDATE PASSWORD PLUGIN and enter Y to continue.

  • VALIDATE PASSWORD PLUGIN can be used to test passwords
  • and improve security. It checks the strength of password
  • and allows the users to set only those passwords which are
  • secure enough. Would you like to setup VALIDATE PASSWORD plugin?
  • Press y | Y for Yes, any other key for No:

Now you must validate your password and make sure it is of a high level with numbers, uppercase, lowercase and special characters.

  • There are three levels of password validation policy:
  • LOW Length> = 8
  • MEDIUM Length> = 8, numeric, mixed case, and special characters
  • STRONG Length> = 8, numeric, mixed case, special characters and dictionary file
  • Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

Now your database system will be configured, you just have to press Y and then Enter for the following questions.

 

by Abdullah Sam
I’m a teacher, researcher and writer. I write about study subjects to improve the learning of college and university students. I write top Quality study notes Mostly, Tech, Games, Education, And Solutions/Tips and Tricks. I am a person who helps students to acquire knowledge, competence or virtue.

Leave a Comment