Install phpmyadmin on your server. Installing PhpMyAdmin Ubuntu on Nginx or Apache


Hello, dear readers of the blog site. Today I want to talk about a script (program) PhpMyAdmin, which helps in a convenient graphical form (without entering SQL queries) to manage databases on the MySQL server. Depending on the user's access level, using this server script you can manage both individual databases and the entire MySQL server.

I don’t plan to go deeper, because... firstly, I’m simply not familiar with the full functionality of this free utility, and secondly, you’re unlikely to need it when working with your website.

However, the PhpMyAdmin program became the same for me. True, although I use it constantly, as a rule, for a very limited number of operations. Mainly, when I want to create a website database, optimize database tables, and in rare cases, it helps me make changes to all article texts at once, which significantly saves time.

Installation and configuration of PhpMyAdmin

It goes without saying that PhpMyAdmin has much more capabilities, but this is quite enough for me. Although, when I studied Popov’s video course on PHP and MySQL, I used this program to create my own databases and to create the necessary tables with the necessary fields in these databases.

In general, in this video course, Evgeniy talks about writing his own CMS (not as complex and sophisticated, of course, as, for example, but still having an admin panel) using PHP and the MySQL query language. Along the way, you naturally learn the basics of these languages, which will come in handy and will be useful when working with your own website. The course is very large and voluminous, but, in my opinion, useful, especially for beginners in this matter.

PhpMyAdmin will be installed on the vast majority of hosting sites (at least on the RuNet) to provide webmasters with the ability to work with their databases. Databases are created, as a rule, using the hosting control panel itself (), but working with an already created MySQL database for almost all hosters is left to PhpMyAdmin, and this is correct, because it is very well suited for this, and the script itself is familiar to many .

That. You most likely won’t need to install and configure this program itself, but I will still, just in case, briefly tell you where you can download the script and how to install and configure it. By the way, this program can be used not only on the hosting server, but also on a local server with MySQL installed. The script is already included by default.

In general, it’s hard for me to imagine a situation where you might need to install and configure PhpMyAdmin yourself, although I’ve encountered such a situation. A year and a half ago, the blog site was hosted by, where at first this script was not installed and I had to download and install it myself, although there is nothing complicated about it.

Download PhpMyAdmin with support for the Russian language, you can from this page, although you can also download a version of the script with support for only the English language from there. The latest current version is 4.0.5 and it will be compatible with PHP 5 and MySQL 5.

Version 2.11.11.3 is compatible with older versions of PHP 4+ and MySQL 3+. After downloading the program archive, you will need to unpack it and connect to your website via FTP, for example, using .

Create a directory in the root folder (usually either PUBLIC_HTML or HTDOCS) of your site with any name you understand, for example, “myadmin” (if you use capital letters in the name of the directory, then when accessing it from the address bar of the browser you will have to take into account character case).

Well, now, using FileZilla, copy the contents of the archive with the script into the created directory (the whole bunch of folders and files from the distribution can be selected at once by pressing Ctrl+A on the keyboard) and click on the “Upload to server” item, selecting it from the context menu:

Once the files are copied (this is install PhpMyAdmin) you need to pre-configure this script. The easiest way to set this up is to rename the file "config.sample.inc.php" (from the "myadmin" folder you created) to "config.inc.php".

After this, open the resulting file “config.inc.php” for editing and proceed with the settings, which consist of setting an identifier that helps encrypt your password for accessing PhpMyAdmin in the browser cookie. To do this, in the line:

$cfg["blowfish_secret"] = "";

Enter at least 10 characters between single quotes, like this:

$cfg["blowfish_secret"] = "sjkdflscokdkld";

You do not need to remember the entered sequence. Actually, the preliminary setup of PhpMyAdmin can be considered complete. Although, you can also change the default login method, which is specified in the line:

$cfg["Servers"][$i]["auth_type"] = "cookie";

In this case, you will have to enter your username and password each time to log in, which can be remembered in a cookie using the browser. But you can replace this line with this code:

$cfg["Servers"][$i]["auth_type"] = "config"; $cfg["Servers"][$i]["user"] = "your_logint"; $cfg["Servers"][$i]["password"] = "parol_odnako";";

In the second and third lines of this code, you set the login and password to enter the program, which now you will not need to type (automatic login). But this login method is less secure than the default one, although if you are working with the site on local host, then this login setup will be preferable.

Export and import database via PhpMyAdmin

After you finish setting up, you can try to log in. To do this, you need to type in the address bar of your browser the path to the folder where you installed the PhpMyAdmin distribution files. That is, for example, for my blog this address would look like this:

Https://site/myadmin/index.php

If you installed and configured the script correctly, a window will appear prompting you to enter your login and password to enter the program:

To login, you can use the username and password that your host gave you. If you install PhpMyAdmin on your server, the login will be “root” by default, and the password is the one you specified when installing MySQL. As a result, you will be taken to the main page of the script:

The house icon will always allow you to return to the initial page of the program. Let's look at the actions that users most often perform - creating and restoring a database backup. In general, of course, you can create a database backup in many ways, but backups made through Php My Admin have never failed me.

There are scripts and extensions for various CMSs that can create database backups on a schedule and without your participation at all, but I personally prefer to use manual backups (I feel safer that way). The database of various CMS contains the most valuable thing that you have on your site - the articles you wrote, the loss of which would be irreplaceable.

In the left column of the PhpMyAdmin interface, select the database you want to backup, then go to the “Export” tab from the top horizontal menu of the main program window:

This program can archive a backup copy of the database on the fly, so at the very bottom of the page that opens it makes sense to check the “gzip” box, thereby reducing the volume and time of downloading. In the “Export” column, by default, all tables from the database you need will be selected and the format for saving it as “SQL” will be selected.

If you want to copy only some tables, then select only them. To create a backup in PhpMyAdmin, you just need to click on the “ok” button and select a location on your computer to store the archive. Actually, everything is quick and simple. The only thing you need to do is remember to repeat this procedure after adding new materials to the site.

Now let's think back to that sad moment when you may need restore database from a previously created backup. First, it is better to delete all existing tables in the database being restored. To do this, click on its name in the left column of the program and, under the list of all database tables, click on “Mark all” and select “Delete” from the drop-down list:

After that, you go from the top menu of the main PhpMyAdmin window to the “Import” tab, click on the “Select file” button and start scouring your computer in search of the latest up-to-date backup copy of the database you need.

The program will take some time to extract and restore all database tables from the archive, after which you can again enjoy a fully functional website. Everything is also very simple and fast, which is good news.

Creating a new database and user in PhpMyAdmin

If you are creating a website on your own server (local, virtual or dedicated), then you may need create a new database, which can be easily done in this program. To do this, on the initial page you will only need to enter its name in the “Create a new database” field and click the create button. That's it, a new database has been created in PhpMyAdmin.

Now we will need to create a user for this database - on the initial page, follow the “Privileges” link:

And in the window that opens you need to follow the link "Add new user":

  1. Username - enter the desired name in Latin (it will be your login when logging in)
  2. Host - usually enter localhost
  3. Password and Confirmation - come up with a more complex password so that the enemy does not guess

In the “Global Privileges” area, select the capabilities that will be provided to the user you create. For a local server, it would be best to click on the “Mark all” link:

Well, we also successfully created a new user in PhpMyAdmin.

Other ways to use PhpMyAdmin

I once had a case when, after moving my site to another server, it began to generate a database error. Having opened the program, I saw a message that one of the tables in my database was damaged.

But this problem was solved quite simply and quickly using PhpMyAdmin itself. To do this, I checked the damaged table and selected the “Restore table” option from the drop-down list below.

In addition, quite often I use the option on table optimization who need this optimization. To do this, just click at the very bottom of the list of tables on the “Mark those requiring optimization” link and select the “Optimize table” option from the drop-down list:

Well, I also sometimes use this opportunity to run SQL queries on certain database tables. It's very convenient when you need change something in the texts of all articles on your website. If the number of articles has exceeded a hundred, then doing this manually is simply not possible. The same can be done by installing the necessary extension on your CMS, but you can get by with PhpMyAdmin alone.

Attention!!! Before you perform the following steps , be sure to make a backup database in the manner described above.

In WordPress, articles are stored in a table called “wp_posts”, so to make changes to the texts of all articles you need to click on the name of this table in the left column of the program window, and in the central window go to the “Browse” tab from the top menu:

A separate window will open in which you will need to type SQL query text, making changes to all articles on the site. This text will look something like this:

UPDATE wp_posts SET post_content =REPLACE(post_content, "what_needs_change", "what_needs_change");

The last time I changed the heading levels inside articles (I removed h4 level headings, replacing them with h3) and sequentially executed the following SQL queries through PhpMyAdmin:

UPDATE wp_posts SET post_content =REPLACE(post_content, "

", "

"); UPDATE wp_posts SET post_content =REPLACE(post_content, "

", ""););

To the right of the SQL query input area in the PhpMyAdmin window, you can select only those fields in which you want to make changes. Article texts in WordPress are written in the “post_content” field:

There are many more ways to use this program to perform day-to-day database operations.

If you know any other useful features of PhpMyAdmin, then post a link in the comments, or explain the essence of the matter in words.

Good luck to you! See you soon on the pages of the blog site

You might be interested

Windows clipboard and saving its history in Clipdiary
Dropbox - how to use cloud data storage, as well as working with the Dropbox program on a computer and mobile Programs for promotion on Instagram
KeePass is a complex password manager and generator, as well as the best program for storing and conveniently using passwords
Notepad++ - free Html and PHP editor with syntax highlighting, overview of features and the best plugins for Notepad++
How to check a site for broken links - Xenu Link Sleuth, plugin and online service Broken Link Checker, as well as search engines
Artisteer - a program for creating and editing templates for Joomla and themes for WordPress
Punto Switcher - free keyboard layout switch and other features of the Punto Switcher program
Gzip compression to speed up site loading - how to enable it for Js, Html and Css using the .htaccess file
How to put a password on a folder (archive or otherwise password protect it in Windows)

PhpMyAdmin is the most popular web-based MySQL database management tool. An indispensable tool for everyone who is not familiar with the MySQL server command language.

For phpMyAdmin to work, you must already have it installed and working.

  • MySQL server
  • Http server with php support

Installation on Ubuntu

Installation is performed with the command

Sudo aptitude install phpmyadmin

The installer will ask which http server we are installing on - I chose apache2, because... he was already standing with me. Next, the installation script asked to create and configure the phpmyadmin database - we agree and enter the user and password to manage this database.
After installation, all configs are stored in /etc/phpmyadmin. Just in case, restart the http server.

Sudo /etc/init.d/apache2 restart

In the browser we enter http://localhost/phpmyadmin/ and log in as MySQL server users.

Installation from source

To give you an idea of ​​what happens when you install phpMyAdmin, I'll show you what the installation scripts for many distributions do. In addition, the installation method from source is universal and suitable for all Unix systems.
1. Download the latest version of phpMyAdmin from the official website (as of today, the latest version was 3.3.8).
2. Unpack the downloaded archive into any folder in the root directory of our http server. For convention, let this be the phpmyadmin folder.
3. Find it in the folder phpmyadmin/scripts the create_tables.sql file is a dump of the phpmyadmin table. Let's restore it with a command from root or sudo

#mysql -u root -p< create_tables.sql

4. We go to the MySQL server console and set the rights to the newly created phpmyadmin database.

# mysql -u root -p mysql> use phpmyadmin; mysql> GRANT ALL ON phpmyadmin.* TO phpmyadmin@localhost IDENTIFIED BY "your_password"; mysql> flush privileges;

5. Edit the configuration file in the root phpmyadmin folder - config.sample.inc.php.
Rename it to config.inc.php, set the owner of the file to the one from whom the http server is running (for me this is the user nobody) and set the file permissions to 600 (we perform these actions as root or sudo)

#mv config.sample.inc.php config.inc.php #chown nobody config.inc.php #chmod 600 config.inc.php

In the file itself config.inc.php change the value of the lines - enter the password for authorization via cookie and the user name, password for the phpmyadmin database restored from the dump.

$cfg["blowfish_secret"] = "password"; /* User for advanced features */ $cfg["Servers"][$i]["controluser"] = "phpmyadmin"; $cfg["Servers"][$i]["controlpass"] = "your_password";

and let’s uncomment these lines

/* Advanced phpMyAdmin features */ $cfg["Servers"][$i]["pmadb"] = "phpmyadmin"; $cfg["Servers"][$i]["bookmarktable"] = "pma_bookmark"; $cfg["Servers"][$i]["relation"] = "pma_relation"; $cfg["Servers"][$i]["table_info"] = "pma_table_info"; $cfg["Servers"][$i]["table_coords"] = "pma_table_coords"; $cfg["Servers"][$i]["pdf_pages"] = "pma_pdf_pages"; $cfg["Servers"][$i]["column_info"] = "pma_column_info"; $cfg["Servers"][$i]["history"] = "pma_history"; $cfg["Servers"][$i]["tracking"] = "pma_tracking"; $cfg["Servers"][$i]["designer_coords"] = "pma_designer_coords";

Now you can type in the browser http://localhost/phpmyadmin/ and log in.

Solving problems when installing phpMyAdmin

1. When opened by a browser, phpMyAdmin does not open, but offers to download the page.
The solution is to configure php support on the http server. In apache, the php module is connected in httpd.conf lines,

LoadModule php5_module modules/libphp5.so

of course php must be installed after the change httpd.conf restart apache server

Mysql -u user -p

3.
Unable to load mcrypt extension! Check your PHP settings.
Solution - make sure that the application is installed on your system mcrypt and library libmcrypt, and the php module for the http server was built with the variable

With-mcrypt

4. After authorization an error occurs:
When working with multi-byte encodings without the PHP "mbstring" extension installed, phpMyAdmin is unable to properly split strings, which can lead to unpredictable results. Install the PHP extension "mbstring".
The solution is to rebuild the php module for the http server with the parameter

Enable-mbstring

or uncomment in php.ini line

Extension=mbstring.so

5. After logging into phpMyAdmin we see a warning:
When using cookie authentication, you must specify a passphrase in the configuration file by setting the value of the $cfg["blowfish_secret"] directive.
The solution is in the phpMyAdmin configuration file - config.inc.php set the password in the line

$cfg["blowfish_secret"]

If you have or have had other errors during installation or configuration, please write in the comments and we will add details..

Article viewed 69,125 times

Today we will look at the installation process of 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 material “Installing and configuring MySQL server and MySQL Workbench on Linux Mint 18.2” we looked at the installation of the MySQL DBMS and the MySQL Workbench client application, which has a graphical interface, but many administrators use, as I already 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 installation using a graphical tool ( program manager), and using the Linux terminal.

phpMyAdmin is a free web application with a graphical interface for administering the MySQL DBMS ( MariaDB support is also available). phpMyAdmin was developed using the PHP language and since this is a web application, a web server is required for its functioning, for example, Apache or Lighttpd. The phpMyAdmin application is popular all over the world and it has currently been 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 delete 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 much more.

Installing phpMyAdmin on Linux Mint 18.2

As I already said, we will look at two ways to install phpMyAdmin, and we will start with a simple method suitable for beginners, i.e. using the program manager graphical interface.

On a note! If you want to learn how to use Linux on your home computer without using the command line, I recommend reading my book - “ »

Installing phpMyAdmin using the program manager

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

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

Enter the computer administrator password.


Installing Apache web server

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 is complete when the window displays “ Installed».


Installing phpMyAdmin

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



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


Then there will be a question about the phpMyAdmin database, i.e. if we want to configure it, we leave the checkbox and click “ Forward».


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



The installation is complete when the message “ Installed" After this, you can immediately check the operation of phpMyAdmin.


Installing phpMyAdmin using terminal

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


Installing programs, including phpMyAdmin, must be done as root, so let's switch to this user right away. To do this, write the command sudo -i (or sudo su) and press Enter ( input), then enter the user 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, to do 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 a password for the phpMyAdmin database, click “ Enter", in the next window we confirm the password, i.e. enter it again and press “ Enter».



After this, the installation will be completed.

Configuring Apache to work with phpMyAdmin

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

To do this, we write a command (with root rights), 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 will enable this configuration file.

A2enconf phpmyadmin

Restart Apache

Systemctl restart apache2


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

If necessary, this configuration file can be disabled; for this purpose, there is the a2disconf command. After the Web server, 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. To edit apache2.conf, run the command (as root).

Nano /etc/apache2/apache2.conf

Add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

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

Systemctl restart apache2

Checking the operation of phpMyAdmin, connection to MySQL

In order to check the operation of 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 fine, in other words, both the web server and phpMyAdmin are working.

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


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


Uninstalling phpMyAdmin in Linux Mint 18.2

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

Uninstalling phpMyAdmin using Program Manager

Open the program manager, and in the same way as during installation, find phpMyAdmin. After you open phpMyAdmin in the program manager, you need to click on the “ Delete».


During the removal process, we will be asked if we want to delete the phpMyAdmin database settings, we leave the checkbox, i.e. delete the settings, click " Forward».


Then there will be a question whether we want to delete the phpMyAdmin database, we check the box and click “ Forward", i.e. We will delete the phpMyAdmin database as we no longer need it ( If you need it accordingly, then you do not check the box).


The phpMyAdmin field 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 run the command ( with superuser rights).

A2disconf phpmyadmin

And restart Apache

Systemctl restart apache2


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


During the Apache removal process, you will not have any additional questions.

Uninstalling phpMyAdmin using Terminal

To remove phpMyAdmin using terminal, we have to launch it accordingly. Then we get root rights using sudo -i (or sudo su), since the deletion must be done with superuser rights.

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

A2disconf phpmyadmin systemctl restart apache2

To remove phpMyAdmin we use the following command.

Apt-get -y --purge remove phpmyadmin

Key --purge means that we want to remove packages along with their configuration files.

During the removal process we will be asked if we want to delete the phpMyAdmin database settings, we answer “ Yes" and click " Enter».


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


As a result, phpMyAdmin will be deleted.


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!

Good day. Today I want to focus on setting up phpMyAdmin. So in one of the articles “Basics of working with phpMyAdmin” we figured out the installation and basic operation of this utility. But the time comes and you want to optimize your work. Now the time has come to optimize your work with phpMyAdmin, and for this you just need to customize it for yourself.

And so... We will configure our phpMyAdmin through the configuration file config.inc.php, which is located in the directory where phpMyAdmin itself is installed. By default this file does not exist. But there is a file config.sample.inc.php. Let's rename it to config.inc.php. Let's look at the default configuration file:

For those who do not have this file, you can download it from here
Now let's look at the configuration file in more detail.
$cfg['blowfish_secret']
In the variable $cfg[‘blowfish_secret’] = ‘123’ we write any combination of characters to encrypt the password. This is necessary for authorization via cookies.
$i
We record the number of servers in the $i variable.
$cfg[‘Servers’][$i][‘auth_type’]
We record the authorization type in the $cfg[‘Servers’][$i][‘auth_type’] variable. There are several types of authorization:

  • cookie - authorization via cookie, authorization is requested
  • config - authorization through a configuration file, i.e. We write the login and password in the same file in variables: $cfg["Servers"][$i]['user'] - for login, $cfg["Servers"][$i]['password'] - for password
  • http - authorization via http authorization
  • signon - authorization using a PHP session (pre-created)

$cfg[‘Servers’][$i][‘host’]
In this variable we enter the host name or IP address of our MySQL server (here you need to specify the IP address of our i-th server)
$cfg[‘Servers’][$i][‘connect_type’]
In $cfg[‘Servers’][$i][‘connect_type’] we enter the MySQL connection type, there are two types:

  • tcp is a standard connection that guarantees work with most MySQL servers
  • socket - for this connection to work, MySQL and phpMyAdmin must be on the same server

$cfg[‘Servers’][$i][‘compress’]
In the $cfg[‘Servers’][$i][‘compress’] variable we include whether the compression protocol will be used to connect to MySQL (true) or not (false)

$cfg[‘Servers’][$i][‘extension’]
In this variable we indicate which MySQL extension to use in php:

  • mysql - classic extension for working with MySQL
  • mysqli is an improved extension and should be used if you have MySQL higher than 4.1.x

$cfg[‘Servers’][$i][‘AllowNoPassword’]
In this variable we allow users to log in without a password (true) or require authorization (false)

$cfg[‘Servers’][$i][‘only_db’]
In this variable we place an array of data consisting of databases that we want to be displayed to this user. For example, $cfg[‘Servers’][$i][‘only_db’] = (‘test’)

$cfg[‘Servers’][$i][‘hide_db’]
To hide certain databases, use this variable
$cfg[‘Servers’][$i][‘hide_db’]. The value of this variable is a regular expression. For example, if we want to hide the test database for a given user, we must write:
$cfg[‘Servers’][$i][‘hide_db’] = ‘test’
That, in principle, is all the basic settings that I would like to consider in this article. But in fact, phpMyAdmin has a lot of settings: restricting access based on various criteria, recording the history of SQL queries, linking tables. You can read about these settings in the official phpMyAdmin documentation. That's all for now. Happy development everyone.

68,516 Views

Phpmyadmin is a popular browser-based tool for managing mysql databases. I almost always install it on the server if there are mysql databases there. It seems to me the simplest and most convenient means of control. In this article I will describe in detail the installation process on the Apache and Nginx web server.

Introduction

I previously touched on the topic of installing phpmyadmin in an article about . Now I want to consider this issue in more detail not only on nginx, but also on traditional apache (httpd).

A few words about what the tool called phpmyadmin is. This is a set of PHP scripts that are installed on a web server. With their help, you can connect to a local or remote mysql server and manage it through a web browser. I most often do the following operations using phpmyadmin:

  1. Creating new databases and users, assigning rights.
  2. Export or import of databases of not very large volume, up to 50 megabytes. If the database is larger, I use command line utilities (mysqldump and mysql) to manage the database server.
  3. View the contents of databases or information about them.

In fact, I do almost all the standard actions with databases. You can do without phpmyadmin; for the simplest server configurations (for example, a bare zabbix server), console utilities are enough for me. But if there is, for example, a web server with websites, I will definitely install phpmyadmin. It's faster and more convenient for me.

Let's get started with a simple installation of phpmyadmin on CentOS 7.

Preparing the apache web server

If you run on a bare server:

# yum install phpmyadmin

You will see a complete list of dependencies, but it will not include the web server itself and the PHP interpreter, only its modules. You need to first install and configure the web server yourself. Let's do this using the httpd (Apache) web server as an example. Install it:

# yum install -y httpd

Now let's install php, without it the administration panel will not work:

# yum install -y php

We launch the web server, add it to startup and check its operation:

# systemctl enable httpd # systemctl start httpd

Visit the address http://ip-address-server. You should see the Apache test page. Now let's check if php is working. Create a test page in the folder /var/www/html:

# mcedit /var/www/html/index.php

We assign the owner of apache to the created file:

# chown apache. /var/www/html/index.php

Now let's go to the address again http://server-ip-address, you should see phpinfo output:

If you see the same output, then everything is fine, the web server is ready to work with phpmyadmin. Let's start installing it.

Installing phpmyadmin

Install phpmyadmin with all dependencies:

After installation in the directory with httpd configurations /etc/httpd/conf.d file appears phpMyAdmin.conf. Let’s save the original file right away, just in case, before we start editing it:

# cp /etc/httpd/conf.d/phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf.orig

By default, in the config, access to the control panel is disabled for all addresses except 127.0.0.1. To open access to everyone, make the file look like this:

# mcedit /etc/httpd/conf.d/phpMyAdmin.conf Alias ​​/phpMyAdmin /usr/share/phpMyAdmin Alias ​​/phpmyadmin /usr/share/phpMyAdmin Require all granted Order Deny,Allow Deny from All Allow from None Order Deny,Allow Deny from All Allow from None

I removed everything unnecessary from the file, including settings that were specific to apache 2.2. Restart httpd:

# systemctl restart httpd

We go to the address . You should see the login page:

At that moment I realized that I had nowhere to log in. There is no mysql on the test server where I am preparing this article. If you have the same situation as me, install mariadb. I talked about it in detail in the article on setting up a web server, you can see all the details there. Now we quickly install the database and launch it:

# yum install -y mariadb mariadb-server # systemctl enable mariadb.service # systemctl start mariadb # /usr/bin/mysql_secure_installation

After this, you can open the phpmyadmin web interface again and log in as root. The main page of the panel will open with general information about the server:

At this point, the installation is complete, the web panel can be used. We will look at some useful settings further in the corresponding section, but now we will install phpmyadmin on the nginx web server.

Installation on nginx

Let's set up phpmyadmin on the nginx + php-fpm web server. I discussed in detail the issue of setting up such a server earlier in the article. There we were talking specifically about the web server and the bias was in this direction. But phpmyadmin may be needed not only on web servers. So let's look at the general case of quickly and easily setting up phpmyadmin on nginx.

Install nginx:

# yum install -y nginx

Install php-fpm:

# yum install -y php-fpm

We start the services and add to startup:

# systemctl start nginx.service # systemctl enable nginx.service # systemctl start php-fpm.service # systemctl enable php-fpm.service

We go to the address http://server-ip-address and check. You should see the nginx test page:

# yum install -y phpmyadmin

Edit the nginx configuration file to add the installed web control panel:

# mcedit /etc/nginx/nginx.conf

We bring the server() section to the following form:

Server ( listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; index index.php index.html index.htm; location ~ \.php$ ( fastcgi_pass 127.0.0.1 :9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_ignore_client_abort off; ) include /etc/nginx/default.d/*.conf; location / ( ) error_page 404 /404.html; location = /40x. html ( ) error_page 500 502 503 504 /50x.html; location = /50x.html ( ) )

# ln -s /usr/share/phpMyAdmin /usr/share/nginx/html/phpmyadmin

Restart nginx:

# systemctl restart nginx

Then, in theory, everything should work, but it didn’t work for me, I had to restart the entire server because the php mbstring module did not work, although it was installed and connected. Restarting php-fpm didn't help either, but rebooting did. I checked it twice and reproduced the error both times. I didn’t try to figure out the reason for this behavior, just restart the server and continue.

Let's go to the address http://server-ip-address/phpmyadmin. You should see the standard login page. I had a warning on it:

Warning in ./libraries/session.inc.php#105 session_start(): open(/var/lib/php/session/sess_j0r4moac0oo7oh250e6t14rn1kfkl6ta, O_RDWR) failed: No such file or directory (2)

This has to do with what's in the folder /var/lib/php no session directory Let's fix this:

# cd /var/lib/php/ # mkdir session # chown apache:apache session/

Please note that I assigned the owner of the session folder to the user apache, although we have an nginx web server. This is due to the fact that php-fpm runs under the apache user by default. It makes more sense to change this and run it from nginx. To do this, you need to edit the /etc/php-fpm.d/www.conf file, changing the user and group parameters there. I didn't do this now for simplicity. I leave this option at your discretion.

Reload the page, the error should disappear. You can connect to mysql. If you do not have a database server installed, see above how to quickly install and launch it. Now that the installation is complete, let's look at a few useful phpmyadmin settings.

Setting up phpmyadmin

Phpadmin is ready to work immediately after installation; additional settings are not required. I’ll give a useful example of use - restricting access to phpmyadmin using web server tools. To use the panel, you will need to not only know the mysql account name, but also the user and password to access the panel directly.

Let's first consider an example with a web server apache. We will use a standard tool to restrict access to a directory using .htaccees. Let's create the following file in the phpmyadmin scripts folder:

# mcedit /usr/share/phpMyAdmin/.htaccess AuthName "Enter Password" AuthType Basic Require valid-user AuthUserFile "/usr/share/phpMyAdmin/.htpasswd"

AddDefaultCharset UTF-8 Require all granted AllowOverride All

Restart Apache and check the settings. When you access the web panel address, an authorization window should pop up:

Let's do the same on nginx. We also create a file with a password.htaccess:

# htpasswd -bc /usr/share/phpMyAdmin/.htpasswd user password

If you do not have httpd installed on your server, then most likely you will see the error:

Bash: htpasswd: command not found

The required utility is not in the system. Install htpasswd on centos:

# yum install -y httpd-tools

Create a file with the password again:

# htpasswd -bc /usr/share/phpMyAdmin/.htpasswd user1 password Adding password for user user1

Let's edit the nginx configuration file, adding a new location to the server() section:

Location /phpmyadmin/ ( auth_basic "Enter password"; auth_basic_user_file /usr/share/phpMyAdmin/.htpasswd; )

Save the config, restart nginx and check access to the page. The same login window as with Apache should pop up.

Let's look at a few more useful phpmyadmin settings. After logging into the panel, in the section Settings you will see a message:

Your settings will only be saved for the current session. For permanent storage, you need to connect the phpMyAdmin settings storage module.

Let's connect the necessary module to save the settings. The module is a big word, we just need to create a separate database to store settings and activate some advanced features. The file for creating the database is stored in the phpmyadmin directory at /usr/share/phpMyAdmin/sql/create_tables.sql. We copy the contents of this file and execute it right there, in phpmyadmin in the SQL section:

Now you can go to the settings and change them. I usually disable new version checking. They come out quite often, I’m too lazy to update them anyway, so I don’t need information about new versions. I also disable the logo, you can upload your own. Look through the settings yourself and see what interests you. All points are well documented, you can read what they are responsible for. Sometimes it is useful to display a separate column in the list of tables with information by creation and update date. This is configured in the section Settings -> Main panel -> Database structure.

If you want to connect to a remote mysql server using phpmyadmin, use the connection setup script at http://server-ip-address/phpmyadmin/setup/.

Conclusion

I reviewed the main points for installing and configuring phpmyadmin on the apache and nginx web server. I want to emphasize that this is my personal experience. Perhaps I made a mistake somewhere or am not doing it entirely right. If you notice this, please write in the comments. I will take note and correct the article. I write articles also in order to learn something new myself. Comments on articles help me with this.

  • Ability to select a configuration for the required tasks, manage processes and ensure system security.
  • Proficient in the basic working tools of a system administrator.
  • Understanding of the specifics of deploying, configuring and maintaining networks built on Linux.
  • The ability to quickly solve emerging problems and ensure stable and uninterrupted operation of the system.
  • Test yourself on the entrance test and see the program for more details.




    

    2024 gtavrl.ru.