Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
145 views
in Technique[技术] by (71.8m points)

php - Centos apache cannot access to mariadb

thanks for your time on my subject.

I installed 2 servers with CentOS 7 into my local network. I can access from WEB to DB using mysql command line and access to the DB. But, when i untar wordpress and configure DB ip address into config file, the wordpress webpage inform me that the DB server is not reachable.

I make several test, with hostname instead of IP address, i remove all firewall on both server, i made the wordpress installation using a local database on WEB server with success.

I dump the database from WEB to DB and try to modify again the config file, i received the same error message that DB server is unreacheable.

I made a tcpdump src WEBserv and look tcp package arrival, nothing come from WEBserv to DBserv when i refresh the wordpress index page. I try manual SQL connexion with WEBserver mysql to DBServ, the tcpdump catch the tcp package and connection is on success.

I look apache log (in debug level) to verify is apache webserv try to access to the DBserv and found this :

    [root@nev-web1 httpd]# tail -f *
==> access_log <==
192.168.0.55 - - [06/Jan/2021:16:21:31 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:32 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:33 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:33 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:34 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:34 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:35 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:36 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:36 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"
192.168.0.55 - - [06/Jan/2021:16:21:37 +0100] "GET / HTTP/1.1" 500 2609 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0"

==> error_log <==
[Wed Jan 06 16:21:37.192175 2021] [authz_core:debug] [pid 7291] mod_authz_core.c(809): [client 192.168.0.55:51165] AH01626: authorization result of <RequireAny>: granted
[Wed Jan 06 16:21:37.192188 2021] [proxy:debug] [pid 7291] mod_proxy.c(1123): [client 192.168.0.55:51165] AH01143: Running scheme fcgi handler (attempt 0)
[Wed Jan 06 16:21:37.192193 2021] [proxy_ajp:debug] [pid 7291] mod_proxy_ajp.c(722): [client 192.168.0.55:51165] AH00894: declining URL fcgi://127.0.0.1:9000/var/www/html/index.php
[Wed Jan 06 16:21:37.192196 2021] [proxy_fcgi:debug] [pid 7291] mod_proxy_fcgi.c(972): [client 192.168.0.55:51165] AH01076: url: fcgi://127.0.0.1:9000/var/www/html/index.php proxyname: (null) proxyport: 0
[Wed Jan 06 16:21:37.192199 2021] [proxy_fcgi:debug] [pid 7291] mod_proxy_fcgi.c(979): [client 192.168.0.55:51165] AH01078: serving URL fcgi://127.0.0.1:9000/var/www/html/index.php
[Wed Jan 06 16:21:37.192202 2021] [proxy:debug] [pid 7291] proxy_util.c(2209): AH00942: FCGI: has acquired connection for (*)
[Wed Jan 06 16:21:37.192206 2021] [proxy:debug] [pid 7291] proxy_util.c(2262): [client 192.168.0.55:51165] AH00944: connecting fcgi://127.0.0.1:9000/var/www/html/index.php to 127.0.0.1:9000
[Wed Jan 06 16:21:37.192258 2021] [proxy:debug] [pid 7291] proxy_util.c(2442): [client 192.168.0.55:51165] AH00947: connected /var/www/html/index.php to 127.0.0.1:9000
[Wed Jan 06 16:21:37.192307 2021] [proxy:debug] [pid 7291] proxy_util.c(2818): AH02824: FCGI: connection established with 127.0.0.1:9000 (*)
[Wed Jan 06 16:21:37.209737 2021] [proxy:debug] [pid 7291] proxy_util.c(2224): AH00943: FCGI: has released connection for (*)

So i think it's the WEB local proxy (for php7.2) that don't root the SQL connexion to DBserv, here the php-fpm.conf

[root@nev-web1 html]# cat /etc/httpd/conf.d/php-fpm.conf AddType
text/html .php DirectoryIndex index.php <FilesMatch .php$>  
SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch>

Please, let me know if you have an idea to unlock my situation. Best regards

WEB :

[root@nev-web1 html]# rpm -q centos-release
centos-release-7-9.2009.1.el7.centos.x86_64
[root@nev-web1 html]# php -v
PHP 7.2.24 (cli) (built: Nov  4 2019 10:23:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.24, Copyright (c) 1999-2018, by Zend Technologies
[root@nev-web1 html]# rpm -q httpd
httpd-2.4.6-97.el7.centos.x86_64

DB :

[root@nev-web2 etc]# rpm -q centos-release
centos-release-7-9.2009.1.el7.centos.x86_64
Server version: 5.5.68-MariaDB MariaDB Server

WEB YUM LIST PHP

[root@nev-web1 httpd]# grep php /tmp/yumlist
php-cli.x86_64                         5.4.16-48.el7             @base
php-common.x86_64                      5.4.16-48.el7             @base
rh-php72.x86_64                        1-2.el7                   @centos-sclo-rh
rh-php72-build.x86_64                  1-2.el7                   @centos-sclo-rh
rh-php72-php.x86_64                    7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-bcmath.x86_64             7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-cli.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-common.x86_64             7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-dba.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-dbg.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-devel.x86_64              7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-embedded.x86_64           7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-enchant.x86_64            7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-fpm.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-gd.x86_64                 7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-gmp.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-intl.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-json.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-ldap.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-mbstring.x86_64           7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-mysqlnd.x86_64            7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-odbc.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-opcache.x86_64            7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-pdo.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-pear.noarch               1:1.10.5-1.el7            @centos-sclo-rh
rh-php72-php-pecl-apcu.x86_64          5.1.12-1.el7              @centos-sclo-rh
rh-php72-php-pecl-apcu-devel.x86_64    5.1.12-1.el7              @centos-sclo-rh
rh-php72-php-pgsql.x86_64              7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-process.x86_64            7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-pspell.x86_64             7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-recode.x86_64             7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-snmp.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-soap.x86_64               7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-xml.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-xmlrpc.x86_64             7.2.24-1.el7              @centos-sclo-rh
rh-php72-php-zip.x86_64                7.2.24-1.el7              @centos-sclo-rh
rh-php72-runtime.x86_64                1-2.el7                   @centos-sclo-rh
rh-php72-scldevel.x86_64               1-2.el7                   @centos-sclo-rh
question from:https://stackoverflow.com/questions/65599103/centos-apache-cannot-access-to-mariadb

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

setsebool -P httpd_can_network_connect=1

It's works ... =] Happy and sade in same time (3 days ...)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...