Apache linux phpmyadmin mysql

How to Install LAMP Stack with PhpMyAdmin in Ubuntu 20.04

LAMP stack is the combination of the most frequently used software packages to build dynamic websites. LAMP is an abbreviation that uses the first letter of each of the packages included in it: Linux, Apache, MariaDB, and PHP.

You can use LAMP to build awesome websites with platforms such as WordPress or Joomla for example.

Additionally, by default, MySQL/MariaDB databases are managed from the command-line interface, via the MySQL shell. If you prefer to manage your databases and perform other useful database server operations from a graphical interface, you need to install PhpMyAdmin, a popular PHP-based web application.

If you looking for a LAMP setup for your Ubuntu 20.04, then you should read our LEMP setup guide on Ubuntu 20.04.

In this article, you will learn how to install and configure LAMP with PhpMyAdmin in Ubuntu 20.04 server. The guide assumes that you have already installed Ubuntu 20.04. If you have not installed already, you can refer to our guides here:

Prerequisites:

Step 1: Installing Apache on Ubuntu 20.04

1. Apache2 is an open-source popular, powerful, reliable, and high extensible web/HTTP server software used by numerous websites on the internet.

To install the Apache2 package, use the default package manager as follows:

Install Apache on Ubuntu 20.04

The configuration files for Apache2 are located in /etc/apache2 directory and the main configuration file is /etc//etc/apache2/apache2.conf. And the default document root for storing your web files is /var/www/html/.

2. On Ubuntu unlike on other major Linux distributions, systemd services are automatically started and enabled to start at system boot, when a package (intended to run as a service) installation is complete.

You can confirm that the Apache2 service is up and enabled on boot using the following systemctl commands.

$ sudo systemctl status apache2 $ sudo systemctl is-enabled apache2

Check Apache Service

4. Next, you need to test the correct operation of the Apache2 server installation. Open a web browser and use the following address to navigate.

You should see the Apache Ubuntu default page shown in the screenshot.

Check Apache Default Page

Step 2: Installing MariaDB Database on Ubuntu 20.04

5. MariaDB is a fork of the popular MySQL database. It is now popular too and is the default in most Linux distributions including Ubuntu and is also part of most cloud offerings.

To install the MariaDB database server and client, run the following command.

$ sudo apt install mariadb-server mariadb-client

Install MariaDB on Ubuntu 20.04

The MariaDB configuration files are stored under the /etc/mysql/ directory. There are so many configuration files in there, you can read the MariaDB documentation for more information.

Читайте также:  Setting system time on linux

6. Next, confirm that the MariaDB database service is running and is enabled to automatically start when your system is restarted.

$ sudo systemctl status mariadb $ sudo systemctl is-enabled mariadb

Check MariaDB Service

7. On production servers, you need to enable some basic security measures for the MariaDB database installation, by running the mysql_secure_installation script which ships with the MariaDB package.

$ sudo mysql_secure_installation

After running the script, it will take you through a series of questions where you can answer yes(y) or no(n) to enable some security options. Because the database system has just been installed, there is no database root (or administrator) user password.

So you need to create one as shown in the following screenshot.

Secure MariaDB Server

  • Enter current password for root (enter for none): Enter
  • Set a root password? [Y/n] y
  • 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

8. To access the MariaDB shell, run the mysql command with the -u option with sudo. If you do not use the sudo command, you are bound to encounter the error indicated in the following screenshot.

$ mysql -u root -p $ sudo mysql -u root

Access MariaDB Shell

Step 3: Installing PHP in Ubuntu 20.04

9. A general-purpose open-source scripting language, PHP is one of the most popular programming languages for web development. It powers some of the most popular websites and web applications in the world.

To install PHP, run the following command.

$ sudo apt install php libapache2-mod-php php-mysql

Install PHP in Ubuntu 20.04

The PHP configuration file will be located in /etc/php/7.2/.

Also, depending on your project, you may want to install some PHP extensions required by your application. You can search a PHP extension as shown.

$ sudo apt-cache search php | grep php- #show all php packages

10. After finding the extension, you can install it. For example, I am installing PHP modules for Redis in-memory cache and Zip compression tool.

$ sudo apt install php-redis php-zip

11. After installing PHP extension, you need to restart apache to apply recent changes.

$ sudo systemctl restart apache2

12. Next, test if Apache is working in conjunction with PHP. Create an info.php page under the web document root /var/www/html/ directory as shown.

$ sudo vi /var/www/html/info.php

Copy and paste the following code in the file, then save the file and exit it.

13. Next, open a web browser and navigate using the following address.

http://YOUR_SERVER_IP/info.php

If Apache and PHP are working well together, you should see the PHP information (configuration settings and available predefined variables, installed modules, and more on your system) shown in the following screenshot.

Verify PHP Information

Step 4: Installing PhpMyAdmin in Ubuntu 20.04

14. Intended to handle the administration of MySQL/MariaDB databases, PhpMyAdmin is a free widely-used web-based graphical tool with an intuitive web interface, that supports a wide range of operations on MySQL and MariaDB.

Читайте также:  Acronis for linux server

To install PhpMyAdmin, run the following command.

$ sudo apt install phpmyadmin

Install PhpMyAdmin in Ubuntu 20.04

15. During the package installation, you will be prompted to choose the web server that should be automatically configured to run PhpMyAdmin. Click enter to use Apache, the default option.

Configure Apache to Use PhpMyAdmin

16. Also, PhpMyAdmin must have a database installed and configured before you can start using it. To configure a database for PhpMyAdmin with the dbconfig-common package, select yes in the next prompt.

Configure Database for PhpMyAdmin

17. Next, create a password for PhpMyAdmin to register with the MariaDB database server.

Create a Password for PhpMyAdmin

Once the installation process is complete, the configuration files for phpMyAdmin are located in /etc/phpmyadmin and its main configuration file is /etc/phpmyadmin/config.inc.php. Another important configuration file is /etc/phpmyadmin/apache.conf, used to configure Apache2 to work with PhpMyAdmin.

18. Next, you need to configure Apache2 to serve the phpMyAdmin site. Run the following command to symlink the file /etc/phpmyadmin/apache.conf to /etc/apache2/conf-available/phpmyadmin.conf. Then enable the phpmyadmin.conf configuration files for Apache2 and restart the Apache2 service to apply the recent changes.

$ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf $ sudo a2enconf phpmyadmin.conf $ sudo systemctl reload apache2.service

Enable PhpMyAdmin for Apache2

19. In a browser go to http://SERVER_IP/phpmyadmin, replacing SERVER_IP with the server’s actual IP address.

Once the PhpMyAdmin login page loads, enter root for the username and its password, or another MariaDB user, if you have any setup, and enter the user’s password. If you disabled remote root user login, you can use the phpmyadmin user and password to log in.

PhpMyAdmin Login

20. After login, you will see the PhpMyAdmin dashboard. Use it for managing databases, tables, columns, relations, indexes, users, permissions, etc.

PhpMyAdmin Dashboard

This brings us to the end of this guide. Use the feedback form to ask any questions about this guide or any other LAMP stack related issues concerning Ubuntu 20.04.

Источник

Apache linux phpmyadmin mysql

This tutorial explains how to easily and quickly install an Apache2 web server as well as PHP 8, MariaDB (MySQL) and phpMyAdmin on your Linux root server or VPS/vServer. To do this, please follow these steps.

Hint: You can use the Tab key to autocomplete all filenames and directories, so you don’t have to type in the complete file or directory name manually.

Note : This tutorial explains how to install PHP 8, but if you still want to install and use the previous version PHP 7.4, you can find the appropriate tutorial here.

This tutorial was last checked and updated on April 3, 2023.

Are you looking for very good, powerful and cheap servers? I’ve been renting my servers at Contabo for more than 10 years and I can highly recommend Contabo to everyone!

  1. If you havn’t already done so, download the program «PuTTY».
  2. Connect to your root server or VPS/vServer via SSH using PuTTY. To do this, open PuTTY and enter the domain or IP address of your server in the text box named «Host Name (or IP address)». Then click the «OK» button below.
  3. Update your package lists with the command apt update .
  4. Now install any available updates of the packages already installed on your server using the command apt upgrade -y .
  5. Next, install the packages needed for future installations in this tutorial by executing the following command: apt install ca-certificates apt-transport-https lsb-release gnupg curl nano unzip -y
  6. Add the repository needed to install PHP 8:
    For Debian:
    1. Use the command curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/php-archive-keyring.gpg to add the key needed for the PHP repository.
    2. Add the repository by executing the command echo «deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main» > /etc/apt/sources.list.d/php.list .
    1. Install the package for managing repositories using the following command: apt install software-properties-common -y
    2. Add the repository by executing the command add-apt-repository ppa:ondrej/php and pressing enter.
    1. Now enter the command mysql_secure_installation to complete the configuration of your MariaDB server. At the first question regarding the current password, you don’t have to type in anything, just press enter. Confirm the next question concerning the change of the root password with enter as well. Now you have to set a password for the MariaDB root user. There are no characters displayed during input, but this is normal. Confirm all further questions (deleting the anonymous user, disabling the external root login for security reasons, removing the test database and updating the privileges/permissions) also with enter. Then the MariaDB server is completely installed and configured.
    1. Now enter the command mysql_secure_installation to complete the configuration of your MariaDB server. At the first question regarding the current password, you don’t have to type in anything, just press enter. At the following question regarding switching to Unix socket authentication, type «n» and press Enter. Confirm the next question concerning the change of the root password with enter as well. Now you have to set a password for the MariaDB root user. There are no characters displayed during input, but this is normal. Confirm all further questions (deleting the anonymous user, disabling the external root login for security reasons, removing the test database and updating the privileges/permissions) also with enter. Then the MariaDB server is completely installed and configured.

    # phpMyAdmin Apache configuration

    Alias /phpmyadmin /usr/share/phpmyadmin

    1. Log in to your MariaDB server using the command mysql -u root .
    2. Execute the commands UPDATE mysql.user SET plugin = ‘mysql_native_password’ WHERE user = ‘root’ AND plugin = ‘unix_socket’; as well as FLUSH PRIVILEGES; . This will change the authentication plugin of the root user from the UNIX socket back to standard authentication.
    3. Finally leave the MariaDB console with the command exit .

    Источник

Оцените статью
Adblock
detector