Internet Windows Android

Installing phpmyadmin ubuntu server 14.04. Installing and configuring phpMyAdmin on Ubuntu

Although many users have a need for a database management system like MySQL, working with MySQL using only command line tools can be discomforting.

phpMyAdmin was created to enable users to manage MySQL database using a web interface. In this article, we will show you how to install and configure phpMyAdmin to securely work with your databases on Ubuntu 16.04.

Before installation

Before we start, make sure you have everything you need.

First of all, we will assume that you have a non-root user with sudo privileges. You can set up such a user account by following steps 1-4 in.

Finally, there are some security issues to keep in mind when using phpMyAdmin, as it:

  • Interacts directly with MySQL.
  • Performs authentication using the MySQL login and password.
  • Executes and returns the results of arbitrary SQL queries.

For these reasons, and also because phpMyAdmin is one of the most common and attacked PHP applications, you shouldn't run phpMyAdmin on remote machines with a simple HTTP connection. If you do not yet have a domain with a configured SSL / TLS certificate, we recommend that you read the article.

After completing the steps above, you can start following the steps outlined in this article.

Step 1 - Installing phpMyAdmin

First, install phpMyAdmin from the default Ubuntu repositories.

To do this, let's update our local package index, and then use the apt package management system to download and install the necessary files:

  • sudo apt-get update
  • sudo apt-get install phpmyadmin php-mbstring php-gettext

During the installation process, you will be asked several configuration questions.

Attention:
During the first dialog, apache2 is highlighted, but not selected. If you don't click Space for Apache selection, installer not will move the necessary files during the installation process. Click on Space, Tab, and then Enter to select Apache.

  • When choosing a server, select apache2.
  • Answer yes when asked if you want to use dbconfig-common to configure the database.
  • You will be prompted for the database administrator password.
  • Next, you will be prompted to enter and repeat the password for phpMyAdmin itself.

During installation, the phpMyAdmin configuration file for Apache will be added to the / etc / apache2 / conf-enabled / directory.

The only thing we have to do manually is enable the mcrypt and mbstring PHP extensions with the following commands:

  • sudo phpenmod mcrypt
  • sudo phpenmod mbstring

Now you can access the phpMyAdmin web interface by entering the domain name or public IP address of your server and the / phpmyadmin line:

Https: // domain_name_or_IP_address/ phpmyadmin

You can now log into the web interface using the root username and password that you provided during the MySQL installation.

After logging in, you will see a similar user interface:

Step 2 - Making phpMyAdmin Safer

Installing phpMyAdmin is straightforward. However, we are not finished yet. Because phpMyAdmin is used by a large number of users, it is a popular target for attackers. We need to take some steps to prevent unauthorized access.

One way to achieve this is to authorize the user before logging into the application itself. We can solve this problem by using the capabilities of Apache's .htaccess file to authorize and authenticate users.

Configuring Apache to Allow .htaccess Usage

First, let's enable the use of the .htaccess file in our Apache configuration file.

We will be editing a file in our Apache config directory:

  • sudo nano /etc/apache2/conf-available/phpmyadmin.conf

We need to add the AllowOverride All directive to the section config file:

/etc/apache2/conf-available/phpmyadmin.conf

Options FollowSymLinks DirectoryIndex index.php AllowOverride All. ... ...

Restart Apache to apply the changes:

  • sudo systemctl restart apache2

Creating the .htaccess file

Now that we have enabled .htaccess for our application, we need to create such a file.

The file must be created in the application directory. We can create the required file and open it for editing with the following command:

  • sudo nano /usr/share/phpmyadmin/.htaccess

Now let's enter the following information:

/usr/share/phpmyadmin/.htaccess

AuthType Basic AuthName "Restricted Files" AuthUserFile /etc/phpmyadmin/.htpasswd Require valid-user

The lines we have entered mean the following:

  • AuthType Basic: This string specifies the type of authorization. The specified type (Basic) means that authorization will be based on a password and a password file.
  • AuthName: This string specifies the welcome text in the authorization dialog. Use common words and phrases in this line to make it more difficult for attackers to determine what kind of system is hidden behind the authorization dialog.
  • AuthUserFile: This line specifies the address of the password file that is used for authorization. The file must be located in a directory inaccessible to the outside world. We will create this file a bit further.
  • Require valid-user: This line means that only authenticated users can access the protected system.

After entering the specified lines, save and close the file.

Creating a .htpasswd password file for authentication

Now that we have set the path for our password file in the AuthUserFile directive in our .htaccess file, we need to create this file.

In order to do this, we need to install an additional package from the standard repositories:

  • sudo apt-get install apache2-utils

The htpasswd utility is now available to us.

The path we specified earlier looked like this: /etc/phpmyadmin/.htpasswd. Let's create this file and add the first user to it with the following command:

  • sudo htpasswd -c /etc/phpmyadmin/.htpasswd username

You will be prompted to select and confirm a password for the created user. After that, the file will be created and the hash of the password you specified will be added to it.

To add a new user run the following command without the -c flag:

  • sudo htpasswd /etc/phpmyadmin/.htpasswd additionaluser

Now that you have configured access to the phpMyAdmin subdirectory, when you try to log into phpMyAdmin, you will be prompted to enter your username and password:

Https: // domain_name_or_IP_address/ phpmyadmin

After entering your username and password, you will be redirected to the phpMyAdmin authentication page. Thus, we have created an additional layer of protection for your phpMyAdmin.

Conclusion

You now have phpMyAdmin ready to run on your Ubuntu 16.04 server. Using its interface, you can easily create databases, users, tables and much more, as well as perform the usual operations of modifying or deleting stored data.

Today we will look at the process of installing a very popular web application. phpMyAdmin, which is used to administer the MySQL DBMS, we will install it on the Linux Mint 18.2 operating system.

Let me remind you that earlier in the article "Installing and Configuring MySQL Server and MySQL Workbench on Linux Mint 18.2" we examined the installation of the MySQL DBMS and the MySQL Workbench client application, which has a graphical interface, but many administrators use, as I said, the very popular web application for working with MySQL, phpMyAdmin, so now, especially for beginners, I will describe in detail the process of installing phpMyAdmin on Linux Mint 18.2.

As always, we will look at the installation and using the graphical tool ( program manager), and using the Linux terminal.

phpMyAdmin Is a free web application with a graphical interface for administering MySQL DBMS ( MariaDB support is also there). PhpMyAdmin is developed using PHP language and since this is a web application it requires a web server such as Apache or Lighttpd to function. The phpMyAdmin application is popular all over the world and is currently translated into 72 languages, including Russian.

With phpMyAdmin you can:

  • View databases and tables;
  • Create, copy, rename, modify and delete databases;
  • Create, copy, rename, modify and delete tables;
  • Add, edit and delete fields in tables;
  • Execute SQL queries;
  • Create, modify and drop indexes;
  • Load text files into tables;
  • Create and read dumps of tables and databases;
  • Export data to SQL, CSV, XML, Word, Excel, PDF and LaTeX formats;
  • Manage MySQL users and privileges;
  • And also many other things.

Installing phpMyAdmin on Linux Mint 18.2

As I said, we'll look at two ways to install phpMyAdmin, and we'll start with a simple, beginner-friendly way, i.e. using the graphical interface of the program manager.

Installing phpMyAdmin using the program manager

In order to install phpMyAdmin, you first need to install a web server such as Apache. Therefore, now we will first install Apache and only then phpMyAdmin.

We open the program manager, for example, “ Menu-> Program Manager" or " Menu-> Administration-> Program Manager».

Enter the computer administrator password.


Apache web server installation

In the program manager, enter Apache in the search and press Enter. Then find Apache2 in the search results and double-click on it.



The installation will be completed after the message “ Installed».


Install phpMyAdmin

To install phpMyAdmin in exactly the same way, enter phpMyAdmin in the search and press Enter. Most likely, only one program will be found, which we need, we double-click on it.



During the installation process, you will be asked which web server you will use, since we have already installed Apache, respectively, and answer Apache and click “ Forward».


Then there will be a question about phpMyAdmin database i.e. if we want to customize it, we leave a check mark and click " Forward».


As a setting, we are offered to come up with and enter a password for the phpMyAdmin database, we enter and click “ Forward", Then we confirm it and also press" Forward» ( the password should be quite complex, although you will rarely need it).



The installation will be completed as the message “ Installed". After that, you can immediately check if phpMyAdmin is working.


Install phpMyAdmin using terminal

To launch the Linux terminal, click, for example, on the link on the panel or launch from the Mint menu.


You need to install programs, including phpMyAdmin, as root, so let's switch to that user right away. To do this, write the command sudo -i (or sudo su) and press Enter ( input), then enter the user's password.

Then we need to update the list of packages, for this we write a command.

Apt-get update

Then, as in the case of the program manager, we need to first install the Apache web server, for this we enter the following command.

Apt-get -y install apache2


Apt-get -y install phpmyadmin


During the installation process, we will be asked which web server we will use, we select Apache and click “ Enter».


Then we need to configure the phpMyAdmin database, select “ Yes"And click" Enter».


Then we come up with and enter the password for the phpMyAdmin database, click “ Enter", In the next window we confirm the password, ie. we enter it again, and again press “ Enter».



The installation will then complete.

Configuring Apache to work with phpMyAdmin

If we install phpMyAdmin using the terminal, then in this case, in contrast to the graphical installation using the program manager, we need to manually connect the phpMyAdmin configuration file ( those. phpmyadmin configuration file).

To do this, we write a command (with root privileges), with which we will create a symbolic link in the directory with Apache configuration files.

Ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

Then we include this config file.

A2enconf phpmyadmin

Restart Apache

Systemctl restart apache2


That's it, after that you can proceed to checking the phpMyAdmin operation.

If necessary, this configuration file can be disabled, for this there is the a2disconf command. After the Web, Apache also needs to be restarted.

By the way, you can connect this configuration file in another way, for example, directly register the connection in the apache2.conf file, this method is often found on the network, but the first option in this case is more correct. Run the command (as root) to edit apache2.conf.

Nano /etc/apache2/apache2.conf

Add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

Save the file with the Ctrl + O keyboard shortcut and press Enter, then close it also with the Ctrl + X keyboard shortcut. Apache in this case also needs to be restarted.

Systemctl restart apache2

Checking phpMyAdmin, connecting to MySQL

In order to test phpMyAdmin, let's launch any browser and type the following address in the address bar ( this is the local address of phpMyAdmin).

http: // localhost / phpmyadmin

If you see the phpMyAdmin welcome page, then everything is in order, in other words, both the web server and phpMyAdmin are running.

To connect to the MySQL server, enter the username and password, for example, I will connect as root ( although as you know, it is not recommended to run as root).


After logging in, you will be taken to the phpMyAdmin home page, where you can see the list of databases on the server and the main settings of the MySQL server.


Removing phpMyAdmin in Linux Mint 18.2

You can remove phpMyAdmin both using the program manager and using the terminal. Let's look at both methods as well.

Removing phpMyAdmin using the program manager

We open the program manager, and in the same way as during the installation, we find phpMyAdmin. After you open phpMyAdmin in the program manager, you need to click on the button " Delete».


During the uninstallation process, we will be asked if we want to delete the phpMyAdmin database settings, we leave a check mark, i.e. delete the settings, click " Forward».


Then there will be a question if we want to delete the phpMyAdmin base, we tick the box and click “ Forward", I.e. we will delete the phpMyAdmin database, since we no longer need it ( if you need it accordingly, then you do not check the box).


Then phpMyAdmin will be removed. Now we can disable the phpMyAdmin configuration file in the Apache web server settings. To do this, in the terminal, we need to execute the command ( with superuser rights).

A2disconf phpmyadmin

And restart Apache

Systemctl restart apache2


If you do not need the Apache web server, you can also uninstall it like phpMyAdmin using the program manager.


While uninstalling Apache, you will not have any additional questions.

Removing phpMyAdmin using terminal

To uninstall phpMyAdmin using the terminal, we must start it accordingly. Then we get root rights using sudo -i (or sudo su), since the removal must be done with superuser rights.

To remove only phpMyAdmin, we first need to disable the phpMyAdmin configuration file, for this, as before, we write the following command and restart Apache.

A2disconf phpmyadmin systemctl restart apache2

We use the following command to remove phpMyAdmin.

Apt-get -y --purge remove phpmyadmin

Key —Purge means that we want to remove packages along with their configuration files.

During the uninstallation process, we will be asked if we want to delete the phpMyAdmin database settings, we reply “ Yes"And click" Enter».


Then, when asked about deleting the phpMyAdmin database, we also reply “ Yes", As I said, unless of course you need it.


As a result, phpMyAdmin will be removed.


To remove the Apache web server, write the following command.

Apt-get -y --purge remove apache2

To remove all related packages that we no longer need, we need to use the following command, thereby we can free up disk space.

Apt-get -y autoremove


That's all, I hope the material was useful to you, good luck!

phpMyAdmin is a LAMP application built specifically for administration MySQL servers. Written in PHP and accessible via a web browser, phpMyAdmin provides a graphical interface for database administration tasks.

Installation

Before installing phpMyAdmin, you need access to the MySQL database on the same computer where you install phpMyAdmin, or on a remote computer accessible over the network. See MySQL section for details. To install in the terminal enter:

Sudo apt-get install phpmyadmin

When prompted, select which web server will be configured for phpMyAdmin. This section assumes use as a web server Apache2.

Sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf sudo a2enconf phpmyadmin sudo /etc/init.d/apache2 reload

In your browser, go to http: // localhost/ phpmyadmin... On the login page enter root as a username, or another user if you configured one, as well as the password for this MySQL user.

If in the previous step, when you go to the address http: // localhost/ phpmyadmin, server gives error 404 - Not found, check file location phpmyadmin.conf... In case of ubuntu 12.04: if the file is missing at the address /etc/apache2/conf.d/phpmyadmin.conf and at the same time exists at the address /etc/phpmyadmin/apache.conf then move the file and restart the server: sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf sudo /etc/init.d/apache2 restart

After that, try logging in through your browser again.

Customization

The phpMyAdmin configuration files are located in / etc / phpmyadmin. The main configuration file is /etc/phpmyadmin/config.inc.php. This file contains configuration options that apply to phpMyAdmin globally.

To use phpMyAdmin to manage MySQL on another server, configure the following entry in /etc/phpmyadmin/config.inc.php:

$ cfg ["Servers"] [$ i] ["host"] = "db_server";

Replace db_server to the current IP address of the remote database server. Also make sure that the phpMyAdmin machine has permission to access the remote database.

Once configured, log out of phpMyAdmin and log in again and you will be able to access the new server.

The config.header.inc.php and config.footer.inc.php files are used to add HTML top and bottom headers for phpMyAdmin.

, | |

For the correct operation of many web projects, database management systems (DBMS) are needed, for example, MySQL. However, interacting with the system solely using the MySQL command line is not always convenient.

Thanks to phpMyAdmin, users can manage the MySQL system through a web interface. This guide provides step-by-step instructions for installing and securing the phpMyAdmin web interface.

Requirements

To follow this guide, you will need:

  • A non-root user account with sudo privileges (how to create such a user can be found in the article "");
  • Pre-installed LAMP program group (Linux, Apache, MySQL, PHP); for instructions on how to install the LAMP stack on an Ubuntu 14.04 server read.

Once you've completed the prerequisites, you're ready to install phpMyAdmin.

Step 1 - installing phpMyAdmin

phpMyAdmin can be quickly installed from the standard Ubuntu repository.

To do this, update the list of packages on the system, and then download and install the files using the apt package manager:

sudo apt-get update
sudo apt-get install phpmyadmin

In order to customize the installation, you need to answer how many questions.

  • Select apache2 as the server.

Note: If you do not press the spacebar when selecting a server, the installer will not be able to move the necessary files during installation. To select Apache, press Space, Tab, then Enter.

  • When asked if dbconfig-common should be used to configure the database, answer yes.
  • Enter the DBMS administrator password.
  • You will now be prompted to select and confirm a password for the phpMyAdmin application.

During installation, the phpMyAdmin configuration file is added to the / etc / apache2 / conf-enabled / directory, in which it is read automatically.

All that remains is to explicitly enable the php5-mcrypt extension, which can be done with:

sudo php5enmod mcrypt

Then restart Apache to update the configurations:

sudo service apache2 restart

Ready! To open the interface, visit in your browser:

http: // domain_or_IP / phpmyadmin

To log into phpMyAdmin, use the root name and password created during installation. The user interface appears on the screen.

2: securing phpMyAdmin

As you can see, installing and running phpMyAdmin is a fairly straightforward process. However, do not forget that due to its ubiquity, PhpMyAdmin is often attacked by cybercriminals. At this stage, it is necessary to provide the interface with a sufficient level of protection to prevent unauthorized use.

One of the easiest ways to protect phpMyAdmin is to host a Security Gateway. This is done using special Apache files called .htaccess.

Htaccess override activation

First, you need to activate the .htaccess file by editing the Apache configuration file.

So open your Apache config file:

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

To section you need to add the AllowOverride All parameter:


Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
. . .

After entering the required line, save and close the file.

To update the settings, restart the web server:

sudo service apache2 restart

Creating the .htaccess file

The application now supports .htaccess files; you just need to create such a file.

For correct operation, you need to create this file in the application directory. So, to create the desired file and open it in a text editor with root privileges, type:

sudo nano /usr/share/phpmyadmin/.htaccess

You need to add the following code to this file:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

Let's take a closer look at these lines:

  • AuthTypeBasic sets the type of authorization; in this case, password authentication is used using a password file.
  • AuthName contains the message text of the authentication dialog box. To prevent unauthorized users from receiving additional information about the closed application, this message should not contain details, but only general data (for example, "Restricted Files", "Restricted Stuff", "Private Zone", etc.).
  • AuthUserFile specifies the location of the password file that will be used for authorization. It must be located outside of the maintained directories. Such a file will be created later.
  • Requirevalid-user indicates that only authorized users can access this resource. It is this parameter that protects the resource from unauthorized users.

Save and close the file.

Creating the .htpasswd file

Now, in the directory specified in the AuthUserFile line, you need to create a password file.htpasswd.

To do this, you need an additional package containing the htpasswd utility, which can be installed from the standard repository:

sudo apt-get install apache2-utils

Remember, the file must be created in the directory specified in the AuthUserFile directive, in this case /etc/phpmyadmin/.htpasswd.

Create this file and pass it to the user by typing:

sudo htpasswd -c /etc/phpmyadmin/.htpasswd username