After setting up the nginx + php-fpm bundle, you may need phpmyadmin to manage MySQL databases. The most common practice is access through an alias. Slightly less - subdomain. Consider the first option.
First of all, you should install phpmyadmin itself with a simple command:
# aptitude install phpmyadmin
During installation, two questions will be asked. The first is whether to perform automatic configuration for apache and lighttpd web servers. The second is whether to configure phpmyadmin configuration using db-config.
The first question is skipped. If you wish, the second question you can study and perform the appropriate setting. True, phpmyadmin will work fine without it.
Next, open the nginx configuration file and assign the following location to the desired site:
location / pma / { alias / usr / share / phpmyadmin /; location ~ \ .php $ { fastcgi_pass unix: /var/run/php-pool-name.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $ request_filename; fastcgi_ignore_client_abort off; } location ~ * \. (js | css | png | jpg | jpeg | gif | ico) $ { access_log off; log_not_found off; expires 1M; } }
Locations should assign some unique name so that bots do not knock there.
We also set the address of the php pool (tcp or socket, depending on the setting of your server) as the value of the fastcgi_pass parameter.
Finally, add the open_basedir exceptions for the / usr / share / phpmyadmin and / usr / share / php / php-gettext directories. There are two possible options. The first (preferred) one is the parameter in the pool configuration file:
php_admin_value [open_basedir] = "/ usr / share / phpmyadmin: / usr / share / php / php-gettext"
The second option is to add a line in the above location:
fastcgi_param PHP_ADMIN_VALUE "open_basedir = / usr / share / phpmyadmin: / usr / share / php / php-gettext";
After editing the configuration files, restart nginx and php-fpm.
admin site, hello, as you may have noticed me every first letter of the word for some reason is written automatically capitalized. I came across your site only today, I found a lot of well-described articles. But specifically for this article, phpmyadmin was unable to do so, there is no indication that you need to add a symbolic link to the / usr / share / phpmyadmin directory. without it, phpmyadmin did not work. It seems to me that this article is not complete, unlike the rest, written by you. therefore, I rated it only at 3. But in general, the articles on the site are very useful, especially for beginners, like me, everything is very well written and explained in detail. added your site to your favorites, found a lot of useful information, which I can not use for the development of my project! Many thanks!
Yes thank you. Corrected css.
But I doubt about the links. Where to refer to it if the alias in the nginx config leads directly to the phpmyadmin folder? I would be grateful if you add exactly how you solved the problem, because poorly imagine your situation. This config works for me. : /
I'm completely confused, put your config for location / pma / and everything works, even there are no problems with the redirect when cgi.fix_pathinfo 0. Before that, I came across a solution to a redirect problem on this site http://www.samundra.com.np/use-phpmyadmin-with-nginx-and-php7/1374 . The first time I followed your instructions, I did not add “include fastcgi_params; fastcgi_param SCRIPT_FILENAME $ request_filename; "(I don’t know what these two parameters do), and without them, as I now understand, the alias in the config will not work, then actually tried to create a symbolic link and came across a problem with the wrong redirect to phpmyadmin. In general, because of a misunderstanding of how and why the parameters work in the nginx config, I could not follow the instructions of the simple guide))
There is one question: I have only two parameters in the location ~ \ .php $ {include snippets / fastcgi-php.conf; fastcgi_pass unix: /var/run/php5-fpm.sock;} Should I make it as in your nginx + php-fpm article ready config? Thank you in advance!
The difference of the methods is that according to the above link the folder / usr / share is registered as root:
root /usr/share/;
. In this case, you can not change the name of the location / phpmyadmin. Unlike the example here, when a location with any name, even though / asdasd becomes an alias to the / usr / share / phpmyadmin folder. Thus, PMA can be protected from all sorts of bots. :)Of course, in the case of an alias, it should be
fastcgi_param SCRIPT_FILENAME $request_filename;
that is to befastcgi_param SCRIPT_FILENAME $request_filename;
, place standardfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
.Description of variables can be found here: https://nginx.org/ru/docs/varindex.html .
And the configuration with include snippets / fastcgi-php.conf can be left as is. The manual was written using the example of Debian 7, where everything is not so convenient. Fastcgi-php.conf presents a more correct configuration with the string
fastcgi_split_path_info ^(.+\.php)(/.+)$;
. Although it can work on the old instructions. :)ww.kr.ua, thank you very much for such a detailed explanation. I am guilty of my illiteracy, I regret that I rated the article at 3. There are a lot of articles and you never know if you can trust the author and just copy and paste, you don’t know what the result will be and whether you will lead to even more mistakes, so I prefer to do the minimum configurations until I figure everything out myself and I’m not sure that this method is optimal for me. But now I learned)) The site is excellent. thank!
It's my pleasure. :) And the approach is correct. Indeed, some do not even try in practice what is written in the articles. Just to gain traffic. That's why this blog appeared to record what works.