简体   繁体   English

Debian 中的 apache2.4 + php-fpm + phpmyadmin

[英]apache2.4 + php-fpm + phpmyadmin in debian

I have this setup in a debian: apache 2.4 proxy_fcgi and php-fpm (v5.5).我在 debian 中有这个设置:apache 2.4 proxy_fcgi 和 php-fpm (v5.5)。 In my virtualhost file i have:在我的虚拟主机文件中,我有:

<VirtualHost *:80>
DocumentRoot /var/www/html
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi://./var/www/html
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>

and everything works fine, i can see phpinfo() and every php file i request under /var/www/html/.一切正常,我可以看到 phpinfo() 和我在 /var/www/html/ 下请求的每个 php 文件。

I continue with the phpmyadmin installation from the debian repo but when i browse to http://MY.IP/phpmyadmin i get a "File not found" error and in the apache error log我继续从 debian repo 安装 phpmyadmin,但是当我浏览到http://MY.IP/phpmyadmin 时,我收到“找不到文件”错误并在 apache 错误日志中

"[proxy_fcgi:error] AH01071: Got error 'Primary script unknown\n'"

Debian phpmyadmin package dumps the contents into /usr/share/phpmyadmin. Debian phpmyadmin 包将内容转储到 /usr/share/phpmyadmin。 If i create a test.html file under /usr/share/phpmyadmin i can see its contents from http://MY.IP/phpmyadmin/test.html如果我在 /usr/share/phpmyadmin 下创建一个 test.html 文件,我可以从http://MY.IP/phpmyadmin/test.html看到它的内容

The problem is that php files under /usr/share/phpmyadmin are not being processed.问题是 /usr/share/phpmyadmin 下的 php 文件没有被处理。 The phpmyadmin apache configuration is this: phpmyadmin apache 配置是这样的:

# phpMyAdmin default Apache configuration

Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php

        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php
                <FilesMatch ".+\.php$">
                    SetHandler application/x-httpd-php
                </FilesMatch>

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_admin_flag allow_url_fopen Off
                php_value include_path .
                php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
                php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/
        </IfModule>

</Directory>
...

and is loaded in apache configuration file.并加载到 apache 配置文件中。

Since there is no mod_php installed there is no processing for the php files.由于没有安装 mod_php,所以没有处理 php 文件。 How can i tell apache to use proxy_fcgi to process php files under /usr/share/phpmyadmin directory ?如何告诉 apache 使用 proxy_fcgi 处理 /usr/share/phpmyadmin 目录下的 php 文件?

>>update<< I added a proxypassmatch directive in phpmyadmin apache's conf >>update<<我在 phpmyadmin apache 的 conf 中添加了一个 proxypassmatch 指令

ProxyPassMatch ^/phpmyadmin/(.*\.php(/.*)?)$ unix:/var/run/php5-fpm.sock|fcgi:///usr/share/phpmyadmin/

expecting to work but i keep getting the same error.期待工作,但我不断收到同样的错误。

>>update 2<< I replaced the php-fpm unix socket with network (127.1:9000) and replaced the virthualhost file's ProxyPassmatch with: >>update 2<<我用网络 (127.1:9000) 替换了 php-fpm unix 套接字,并将 virthualhost 文件的 ProxyPassmatch 替换为:

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1

and in phpmyadmin's apache conf:并在 phpmyadmin 的 apache conf 中:

ProxyPassMatch ^/phpmyadmin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/phpmyadmin/$1
ProxyPassMatch ^/phpmyadmin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/phpmyadmin$1index.php

and everything works.. when i go to MY.IP/phpinfo.php i get the phpinfo from /var/www/html/phpinfo.php and when i visit MY.IP/phpmyadmin/phpinfo.php i get the processed contents of /usr/share/phpmyadmin/phpinfo.php.一切正常...... /usr/share/phpmyadmin/phpinfo.php。

My problem is solved but i still don't understand why the network connection with php-fpm works but the unix socket doesn't.我的问题解决了,但我仍然不明白为什么与 php-fpm 的网络连接有效,而 unix 套接字却没有。

I was struggling with this exact same issue and I could not get phpmyadmin to work.我正在努力解决这个完全相同的问题,我无法让 phpmyadmin 工作。 I was still getting the "File not found" mentioned above.我仍然收到上面提到的“找不到文件”。 My issue was I had to put mine in my ProxyPassMatch inside of my 000-default.conf file inside of my ./sites-available folder and I had to put these entries BEFORE my default one.我的问题是我必须将我的 ProxyPassMatch 放在我的 ./sites-available 文件夹内的 000-default.conf 文件中,并且我必须将这些条目放在我的默认条目之前。 This was outline at the very bottom of this page where I found the solution: http://jordanconway.com/set-up-apache-2-4-with-php-fpm-on-ubuntu-13-10/这是我在此页面底部找到解决方案的概述: http : //jordanconway.com/set-up-apache-2-4-with-php-fpm-on-ubuntu-13-10/

Here is the way I have mine setup for reference.这是我的设置方式以供参考。

<VirtualHost *:80>
   ...
    DocumentRoot /var/www/html
   ...
    ProxyPassMatch ^/phpmyadmin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/phpmyadmin/$1
    ProxyPassMatch ^/phpmyadmin/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/usr/share/phpmyadmin$1index.php
    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1
</VirtualHost>

这可能是因为Apache 2.4.9 支持套接字并且您可能使用了一些早期的 2.4 版本吗?

Looks like you solved this.看起来你解决了这个问题。

  1. Your PHPMyAdmin was set to use mod_php5, which likely wasn't installed since you are using PHP via PHP-FPM.您的 PHPMyAdmin 被设置为使用 mod_php5,它可能没有安装,因为您是通过 PHP-FPM 使用 PHP。
  2. You correctly identified that phpmyadmin setup required a proxypass which had the correct path to the PHP files.您正确地确定了 phpmyadmin 设置需要具有正确的 PHP 文件路径的 proxypass。

For the last bit, usually php-fpm will listen on a unix socket or on TCP but not both.最后一点,通常 php-fpm 会在 unix 套接字TCP 上侦听,但不会同时侦听两者。 What's the listen directive set to in /etc/php5/fpm/pool.d/www.conf ?/etc/php5/fpm/pool.d/www.conf设置的listen指令是什么? Are there more than one listen directives defined?是否定义了多个listen指令?

I'm guessing there is just the one Listen 127.0.0.1:9000 set in there.我猜那里只有一个Listen 127.0.0.1:9000集。

I needed to add HTTP2 to apache HTTPD and it stopped phpmyadmin from working because of having to remove mod_php.我需要将 HTTP2 添加到 apache HTTPD 并且它停止了 phpmyadmin 的工作,因为必须删除 mod_php。

Open /etc/phpmyadmin/apache.conf打开/etc/phpmyadmin/apache.conf

Comment out注释掉

<IfModule mod_php7.c>

Add in <Directory在<目录中添加

<FilesMatch \.php> # Apache 2.4.10+ can proxy to unix socket
    SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
</FilesMatch>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM