요약 : 새로운 mysqli() 호출은 CLI에서 작동하지만 httpd에서는 작동하지 않습니다.새로운 mysqli() 호출은 cli에서 작동하지만 아파치를 통해 실패 함 httpd
시나리오 : 데이터의 예상 목록에 파일 timetest.php 사용자 아파치 CLI 명령으로
<?php
$res=new mysqli('hostname/ip','myuser','mypass','mydb',3306,'/var/lib/mysql/mysql.sock');
$participants = mysqli_query($res,"myquery");
printf("\tvar panelists=[\n");
$mycount=0;
while ($myrow=mysqli_fetch_object($participants)){
if ($mycount++ > 0){
printf("\t\t,");
} else {
printf("\t\t");
}
printf("{key:%s,label:\"%s\"}\n",$myrow->key,htmlspecialchars($myrow->label));
}
printf("\t\t,{key:0,label:\"unassigned\"}\n\t];\n");
phpinfo();
?>
'PHP는 timetest.php'결과는 쿼리에서 반환.
lynx http://hostname/timetest.php
만 반환 정적 데이터 및 알리는 아파치 오류 로그에 오류 :
[Tue Nov 04 14:04:33.751527 2014] [:error] [pid 30344] [client 10.0.0.1:37130] PHP Warning: mysqli::mysqli(): (HY000/2002): Permission denied in /opt/www/html/timetest.php on line 2
구성 :
페도라 20 아파치 아파치 PHP 버전 => 5.5.17
아파치를 통한 phpinfo와 vli의 비교 :
5,6c5,6
< Build Date => Sep 20 2014 16:26:24
< Server API => Apache 2.0 Handler
---
> Build Date => Sep 20 2014 16:24:06
> Server API => Command Line Interface
79c79
<
---
>
85,139d84
< Apache Version => Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips PHP/5.5.17 mod_wsgi/3.5 Python/2.7.5 mod_perl/2.0.9-dev Perl/v5.18.2
< Apache API Version => 20120211
< Server Administrator => [email protected]
< Hostname:Port => www.greenemyst.com:0
< User/Group => apache(48)/48
< Max Requests => Per Child: 0 - Keep Alive: on - Max Per Connection: 100
< Timeouts => Connection: 60 - Keep-Alive: 5
< Virtual Server => No
< Server Root => /etc/httpd
< Loaded Modules => core mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_dumpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_macro mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_ssl mod_systemd mod_cgi mod_perl mod_php5 mod_wsgi
<
< Directive Local Value Master Value
< engine => 1 => 1
< last_modified => 0 => 0
< xbithack => 0 => 0
<
< Apache Environment
< Variable Value
< UNIQUE_ID => VFgNbKQDyyi4J2-sYw7u2wAAAAM
< HTTP_USER_AGENT => Wget/1.14 (linux-gnu)
< HTTP_ACCEPT => */*
< HTTP_HOST => localhost
< HTTP_CONNECTION => Keep-Alive
< PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
< SERVER_SIGNATURE => no value
< SERVER_SOFTWARE => Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips PHP/5.5.17 mod_wsgi/3.5 Python/2.7.5 mod_perl/2.0.9-dev Perl/v5.18.2
< SERVER_NAME => localhost
< SERVER_ADDR => ::1
< SERVER_PORT => 80
< REMOTE_ADDR => ::1
< DOCUMENT_ROOT => /opt/www/html
< REQUEST_SCHEME => http
< CONTEXT_PREFIX => no value
< CONTEXT_DOCUMENT_ROOT => /opt/www/html
< SERVER_ADMIN => [email protected]
< SCRIPT_FILENAME => /opt/www/html/timetest.php
< REMOTE_PORT => 49043
< GATEWAY_INTERFACE => CGI/1.1
< SERVER_PROTOCOL => HTTP/1.1
< REQUEST_METHOD => GET
< QUERY_STRING => no value
< REQUEST_URI => /timetest.php
< SCRIPT_NAME => /timetest.php
<
< HTTP Headers Information
<
< HTTP Request Headers
< HTTP Request => GET /timetest.php HTTP/1.1
< User-Agent => Wget/1.14 (linux-gnu)
< Accept => */*
< Host => localhost
< Connection => Keep-Alive
< HTTP Response Headers
< X-Powered-By => PHP/5.5.17
<
192,197c137,142
< highlight.comment => #FF8000 => #FF8000
< highlight.default => #0000BB => #0000BB
< highlight.html => #000000 => #000000
< highlight.keyword => #007700 => #007700
< highlight.string => #DD0000 => #DD0000
< html_errors => On => On
---
> highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
> highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
> highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
> highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
> highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
> html_errors => Off => Off
201c146
< implicit_flush => Off => Off
---
> implicit_flush => On => On
208c153
< max_execution_time => 30 => 30
---
> max_execution_time => 0 => 0
211c156
< max_input_time => 60 => 60
---
> max_input_time => -1 => -1
215c160
< output_buffering => 4096 => 4096
---
> output_buffering => 0 => 0
221c166
< register_argc_argv => Off => Off
---
> register_argc_argv => On => On
223c168
< report_zend_debug => On => On
---
> report_zend_debug => Off => Off
603c548
< connect_failure => 1
---
> connect_failure => 0
607c552
< active_connections => 18446744073709551615
---
> active_connections => 0
728a674,677
> pcntl
>
> pcntl support => enabled
>
806a756,764
> readline
>
> Readline Support => enabled
> Readline library => EditLine wrapper
>
> Directive => Local Value => Master Value
> cli.pager => no value => no value
> cli.prompt => \b \> => \b \>
>
837c795
< session.save_path => /var/lib/php/session => no value
---
> session.save_path => no value => no value
867c825
< soap.wsdl_cache_dir => /var/lib/php/wsdlcache => /tmp
---
> soap.wsdl_cache_dir => /tmp => /tmp
977,979c935,957
< PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
< LANG => C
< NOTIFY_SOCKET => @/org/freedesktop/systemd1/notify
---
> HOSTNAME => www.greenemyst.com
> SHELL => /bin/bash
> TERM => xterm
> HISTSIZE => 1000
> USER => root
> LS_COLORS => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
> SUDO_USER => jgreene
> SUDO_UID => 1000
> USERNAME => root
> PATH => /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
> MAIL => /var/spool/mail/root
> PWD => /opt/home/jgreene
> LANG => en_US.UTF-8
> HISTCONTROL => ignoredups
> SHLVL => 1
> SUDO_COMMAND => /bin/bash
> HOME => /root
> LOGNAME => root
> LESSOPEN => ||/usr/bin/lesspipe.sh %s
> SUDO_GID => 1000
> DISPLAY => 10.0.0.253:0.0
> OLDPWD => /etc/php.d
> _ => /bin/php
984,1000c962,986
< _SERVER["UNIQUE_ID"] => VFgNbKQDyyi4J2-sYw7u2wAAAAM
< _SERVER["HTTP_USER_AGENT"] => Wget/1.14 (linux-gnu)
< _SERVER["HTTP_ACCEPT"] => */*
< _SERVER["HTTP_HOST"] => localhost
< _SERVER["HTTP_CONNECTION"] => Keep-Alive
< _SERVER["PATH"] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
< _SERVER["SERVER_SIGNATURE"] => no value
< _SERVER["SERVER_SOFTWARE"] => Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips PHP/5.5.17 mod_wsgi/3.5 Python/2.7.5 mod_perl/2.0.9-dev Perl/v5.18.2
< _SERVER["SERVER_NAME"] => localhost
< _SERVER["SERVER_ADDR"] => ::1
< _SERVER["SERVER_PORT"] => 80
< _SERVER["REMOTE_ADDR"] => ::1
< _SERVER["DOCUMENT_ROOT"] => /opt/www/html
< _SERVER["REQUEST_SCHEME"] => http
< _SERVER["CONTEXT_PREFIX"] => no value
< _SERVER["CONTEXT_DOCUMENT_ROOT"] => /opt/www/html
< _SERVER["SERVER_ADMIN"] => [email protected]
---
> _SERVER["HOSTNAME"] => www.greenemyst.com
> _SERVER["SHELL"] => /bin/bash
> _SERVER["TERM"] => xterm
> _SERVER["HISTSIZE"] => 1000
> _SERVER["USER"] => root
> LS_COLORS => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
> SUDO_USER => jgreene
> SUDO_UID => 1000
> USERNAME => root
> PATH => /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
> MAIL => /var/spool/mail/root
> PWD => /opt/home/jgreene
> LANG => en_US.UTF-8
> HISTCONTROL => ignoredups
> SHLVL => 1
> SUDO_COMMAND => /bin/bash
> HOME => /root
> LOGNAME => root
> LESSOPEN => ||/usr/bin/lesspipe.sh %s
> SUDO_GID => 1000
> DISPLAY => 10.0.0.253:0.0
> OLDPWD => /etc/php.d
> _ => /bin/php
984,1000c962,986
< _SERVER["UNIQUE_ID"] => VFgNbKQDyyi4J2-sYw7u2wAAAAM
< _SERVER["HTTP_USER_AGENT"] => Wget/1.14 (linux-gnu)
< _SERVER["HTTP_ACCEPT"] => */*
< _SERVER["HTTP_HOST"] => localhost
< _SERVER["HTTP_CONNECTION"] => Keep-Alive
< _SERVER["PATH"] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
< _SERVER["SERVER_SIGNATURE"] => no value
< _SERVER["SERVER_SOFTWARE"] => Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips PHP/5.5.17 mod_wsgi/3.5 Python/2.7.5 mod_perl/2.0.9-dev Perl/v5.18.2
< _SERVER["SERVER_NAME"] => localhost
< _SERVER["SERVER_ADDR"] => ::1
< _SERVER["SERVER_PORT"] => 80
< _SERVER["REMOTE_ADDR"] => ::1
< _SERVER["DOCUMENT_ROOT"] => /opt/www/html
< _SERVER["REQUEST_SCHEME"] => http
< _SERVER["CONTEXT_PREFIX"] => no value
< _SERVER["CONTEXT_DOCUMENT_ROOT"] => /opt/www/html
< _SERVER["SERVER_ADMIN"] => [email protected]
---
> _SERVER["HOSTNAME"] => www.greenemyst.com
> _SERVER["SHELL"] => /bin/bash
> _SERVER["TERM"] => xterm
> _SERVER["HISTSIZE"] => 1000
> _SERVER["USER"] => root
> _SERVER["LS_COLORS"] => rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
> _SERVER["SUDO_USER"] => jgreene
> _SERVER["SUDO_UID"] => 1000
> _SERVER["USERNAME"] => root
> _SERVER["PATH"] => /usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
> _SERVER["MAIL"] => /var/spool/mail/root
> _SERVER["PWD"] => /opt/home/jgreene
> _SERVER["LANG"] => en_US.UTF-8
> _SERVER["HISTCONTROL"] => ignoredups
> _SERVER["SHLVL"] => 1
> _SERVER["SUDO_COMMAND"] => /bin/bash
> _SERVER["HOME"] => /root
> _SERVER["LOGNAME"] => root
> _SERVER["LESSOPEN"] => ||/usr/bin/lesspipe.sh %s
> _SERVER["SUDO_GID"] => 1000
> _SERVER["DISPLAY"] => 10.0.0.253:0.0
> _SERVER["OLDPWD"] => /etc/php.d
> _SERVER["_"] => /bin/php
> _SERVER["PHP_SELF"] => /opt/www/html/timetest.php
> _SERVER["SCRIPT_NAME"] => /opt/www/html/timetest.php
1002,1159c988,995
< _SERVER["REMOTE_PORT"] => 49043
< _SERVER["GATEWAY_INTERFACE"] => CGI/1.1
< _SERVER["SERVER_PROTOCOL"] => HTTP/1.1
< _SERVER["REQUEST_METHOD"] => GET
< _SERVER["QUERY_STRING"] => no value
< _SERVER["REQUEST_URI"] => /timetest.php
< _SERVER["SCRIPT_NAME"] => /timetest.php
< _SERVER["PHP_SELF"] => /timetest.php
< _SERVER["REQUEST_TIME_FLOAT"] => 1415056748.134
< _SERVER["REQUEST_TIME"] => 1415056748
---
> _SERVER["PATH_TRANSLATED"] => /opt/www/html/timetest.php
> _SERVER["DOCUMENT_ROOT"] =>
> _SERVER["REQUEST_TIME_FLOAT"] => 1415058863.3695
> _SERVER["REQUEST_TIME"] => 1415058863
> _SERVER["argv"] => Array
> (
> [0] => /opt/www/html/timetest.php
>)
1160a997
> _SERVER["argc"] => 1
'# ls -ld /var/{,lib/{,mysql/{,mysql.sock}}} drwxr-xr-x. 24 루트 루트 4096 Nov 4 13:27/var/ drwxrwxr-x. 54 루트 루트 4096 Nov 4 12:04/var/lib/ drwxr-xr-x. 24 mysql mysql 16384 Oct 21 11:19/var/lib/mysql/ srwxrwxrwx. 1 mysql mysql 0 10 월 21 일 11시 19 분/var/lib/mysq/mysql.sock' 그것은 소켓에 대한 파일 권한이 있다면 그것을 얻었다. apache 사용자 (httpd가 실행되는 것임)에주의하십시오. 여전히 php cli 호출을 사용하여 작동합니다. 또한 IP를 사용하여 3306 포트를 사용하도록 유도했으며 동일한 증상이 나타납니다. –
죄송합니다. – Aviator
틀림없이 정말 이상합니다. 거의 PHP가 chroot 환경에서 작동하는 것처럼 보이지만 다른 테스트 결과는 그렇지 않다는 것을 보여줍니다. phpinfo의 주된 차이점은 apache2handler에 의한 존재/호출. –