To install lamp on ubuntu 18, we should know that LAMP is abbreviated as Linux, Apache, MySQL, PHP. These 4 programs are among the most popular Open-Source programs in the web world, which are known as Web Stack. Web Stack uses Linux as the operating system, Apache as the webserver, Mysql as the RDBMS (Relational DataBase Management System), and PHP as the object-oriented programming language. Perl or Python programming languages may be used instead of PHP in different projects). The idea of using the word LAMP was first coined by Mr. Michael Kunze in the German magazine C’t in 1998, and in that year the four words were first used in one word.
Despite this naming, it can still not be concluded that these programs were made to work with each other. Each of these programs is a complete and reference program that is available as open-source. (These programs are also called FOSS, meaning free or open-source software). Open Source programs are very flexible because they are accessible to all users, and they are much easier to troubleshoot. Today, the lamp has become a global standard, so that it is available in almost all published Linux to provide a superpower program to the user.
In this article, we are going to explain how to install LAMP on Ubuntu 18 with PhpMyAdmin installation. LAMP is installed on Linux systems to set up and develop websites and software in hosting. PhpMyAdmin is a free, open-source, well-known, well-featured web-based interface for managing MySQL and MariaDB databases. It also supports various databases and has many features that allow you to easily manage your database through a web console, such as importing and exporting information in various formats, creating complex queries, and Useful using the QBE module (or Query by example), managing different servers and so on.
Requirements To Install Lamp On Ubuntu 18
- A Linux VPS With Ubuntu Server 18.04 OS.
- Access to Server Via SSH.
- Root user access using the Sudo command to execute all commands.
Note: You can use a cheap Linux VPS to run your Lamp on it with the ubuntu 18 operating system.
Steps To Install Lamp On Ubuntu 18
Installing each of these programs has its own steps, so we will install them one by one.
Installation Of Apache Web Server
Apache Web Server (HTTP) is one of the most common web servers in the world. In this step, we are going to explain how to install the apache web server on Ubuntu 18.04 along with the firewall setting configuration for HTTP and HTTPS traffics.
Note: I do not need to use the Sudo command because I logged in to the server as a root user. You do not need to use this command if you are also logged in as a root user, otherwise, you should use it.
First, update your server software packages, then install the Apache server using the following commands.
# sudo apt update # sudo apt install apache2
After the installation process is complete, the Apache webserver should start automatically and run at system boot when booting. Also, if you want to know if Apache is running, you can use the following command.
# sudo systemctl status apache2
If your system firewall is active and running, you need to open ports 80 and 443 and respond to user requests to the Apache web server using HTTP and HTTPS, then reload the firewall settings as below.
# sudo ufw allow 80/tcp # sudo ufw allow 443/tcp # sudo ufw reload
Now test your installed Apache with the default apache test page in a browser, using the link below.
http://DOMAIN_NAME/ OR http://SERVER_IP/
Note: If your server is connected to a domain name, enter the domain name in the browser instead of DOMAIN_NAME, otherwise enter the IP of the server instead of SERVER_IP.
If you see the default Apache web server page, it means that your installation was successful. Apache installation is complete, let’s go to the next step.
Installation Of MariaDB
MariaDB Database is a free and open-source database management system that is a branch of MySQL and is an extended project run by leading MySQL developers and when you install lamp on Ubuntu 18, it is better to install MariaDB instead of Mysql.
First, we install the MariaDB database with the following command.
# apt install mariadb-server mariadb-client
After installation, MariaDB services should start automatically, to make sure it is up and running, check its status as below.
# sudo systemctl status mysql
MariaDB is insecure by default, you need to run the following security script to secure it. It then asks you for the root password to make sure that not everyone can log in to the MariaDB database.
# sudo mysql_secure_installation
When you run the script, it asks you to enter the current root password. (Do not enter anything and press Enter). Then enter yes / y in answer to the following security questions.
Set root password? [Y / n]: y
Remove anonymous users? (Press y | Y for Yes, any other key for No): y
Disallow root login remotely? (Press y | Y for Yes, any other key for No): y
Remove test database and access it? (Press y | Y for Yes, any other key for No): y
Reload privilege tables now? (Press y | Y for Yes, any other key for No): y
Installation Of PHP
PHP is one of the most widely used scripting languages on servers, used to generate dynamic content on websites and applications. In this section, we will explain how to install PHP on Ubuntu 18.04. You can install PHP along with other modules (PHP version 7.2 by default) to deploy the web using the following commands.
# sudo apt install php php-common php-mysql php-gd php-cli
After installing PHP, you can test the installed PHP by creating a simple info.php page in your web server document root using the following command.
# nano /var/www/html/info.php
Then add the following content inside this file and save it using ctrl + x.
<? php phpinfo ();
Then open a browser, enter the following address in it to view your server’s PHP information page.
http://DOMAIN_NAME/info.php OR http://SERVER_IP/info.php
Installation Of PhpMyAdmin
In this section, we are going to explain how to install PhpMyAdmin on Ubuntu Linux 18.04. PhpMyAdmin is an interactive web interface for managing databases. In this regard, some users may not feel comfortable with MySQL commands and manage their databases and meet their needs through the web interface so it’s better to install PHPmyadmin too when you install lamp on Ubuntu 18.
You can easily install PhpMyAdmin using the following command to manage the MySQL / MariaDB database through a web browser.
# sudo apt install phpmyadmin
During the package installation process, asks you to select the webserver that should be configured automatically to run PHPMyAdmin, just select the apache2 option with the space key, then press Enter.
Then, enter the MySQL / MariaDB admin password, and then the installer can create a database in PHPMyAdmin.
Once everything is done, you can restart the apache2 service to apply the latest changes.
# sudo systemctl restart apache2
Note: If the PhpMyAdmin package could not work automatically with the Apache web server, follow the instructions below to copy the PHPMyAdmin config file to apache from / etc / PHPMyAdmin / to / etc / apache2 / conf-available / (existing config files directory On the Apache Web Server) and then enable it using the a2enconf tool, and finally restart the Apache service to see the changes made.
# sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf # sudo a2enconf phpmyadmin # sudo systemctl restart apache2
Finally, to access the PHPMyAdmin web interface, enter the following address in a browser as shown below.
http://DOMAIN_NAME/phpmyadmin OR http://SERVER_IP/phpmyadmin
Note: If you are unable to login with the root user (because we have to run MySQL 5.7 with Sudo), you will probably need to create a new admin user to access the MariaDB shell. To create this user, you must log in with the root user in the terminal and run the following command.
# sudo mysql -u root -p
Enter the password of MySQL and run the following commands.
MariaDB [(none)]># CREATE USER 'admin' IDENTIFIED BY '@NewPass1'; MariaDB [(none)]># GRANT ALL PRIVILEGES ON *. * TO 'admin' WITH GRANT OPTION; MariaDB [(none)]># FLUSH PRIVILEGES;
You can now enter the PHPMyAdmin web interface with the new admin username and password you set for it.
In this topic, we explained how to install lamp on ubuntu 18. I hope you enjoyed this tutorial and found it useful. If you have any problem with any of the steps, you can let us know in the comments section.