在何处取消设置或更改$_SERVER['LD_LIBRARY_PATH']?

分享于 

6分钟阅读

互联网

 

问题:

在PHP输出中,如何更改或消除这个变量$_SERVER['LD_LIBRARY_PATH']?

假定apache2.4已安装到/apache24.


==userX-fpm-pool.conf==


[userX]


user = userX


group = userX


listen = 127.0.0.1:9003


clear_env = yes


env['LD_LIBRARY_PATH'] = /fakepath



==php.ini==


variables_order ="GPCS"



==userX-vhost.conf==


<VirtualHost *:80>


 ServerName userX.xxxxxx.com



 ServerAdmin webmaster@localhost


 DocumentRoot /userX/home/www



 UnsetEnv LD_LIBRARY_PATH



 <Directory /userX/home/www>


 Options Indexes FollowSymLinks


 DirectoryIndex index.php index.html


 Require all granted


 AllowOverride All


 </Directory>



 ProxyPassMatch"^/(.*.php(/.*)?)$""fcgi://127.0.0.1:9003/"


</VirtualHost>



==index.php==


<?php


print_r($_ENV);


print_r($_SERVER);



curl输出:


curl -H"Host: userX.xxxxxx.com" http://127.0.0.1


Array


(


)


Array


(


 [LD_LIBRARY_PATH] => /apache24/lib --> How do I change or get rid of this variable?


 [USER] => userX


 [HOME] => /home


 [SCRIPT_NAME] => /index.php


 [REQUEST_URI] => /


 [QUERY_STRING] =>


 [REQUEST_METHOD] => GET


 [SERVER_PROTOCOL] => HTTP/1.1


 [GATEWAY_INTERFACE] => CGI/1.1


 [REMOTE_PORT] => 49248


 [SCRIPT_FILENAME] => //index.php


 [SERVER_ADMIN] => webmaster@localhost


 [CONTEXT_DOCUMENT_ROOT] => /userX/home/www


 [CONTEXT_PREFIX] =>


 [REQUEST_SCHEME] => http


 [DOCUMENT_ROOT] => /userX/home/www


 [REMOTE_ADDR] => 127.0.0.1


 [SERVER_PORT] => 80


 [SERVER_ADDR] => 127.0.0.1


 [SERVER_NAME] => userX.xxxxxx.com


 [SERVER_SOFTWARE] => Apache/2.4.43 (Unix) OpenSSL/1.1.1 PHP/7.4.4


 [SERVER_SIGNATURE] =>


 [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


 [HTTP_ACCEPT] => */*


 [HTTP_USER_AGENT] => curl/7.58.0


 [HTTP_HOST] => userX.xxxxxx.com


 [FCGI_ROLE] => RESPONDER


 [PHP_SELF] => /index.php


 [REQUEST_TIME_FLOAT] => 1587830093.9565


 [REQUEST_TIME] => 1587830093


)




答案1:

不要"print_r($_SERVER);" 它不会出现在你的输出中,启动Apache时设置的环境变量,您可以在Apache启动脚本或Apache配置中对其进行操作。


答案2:

解决方案是注释掉LD_LIBRARY_PATH设置,并将envvars文件中httpd-2.4.3 env value的bin目录中的export行更改为所需的FPM,


==envvars==


# Licensed to the Apache Software Foundation (ASF) under one or more


# contributor license agreements. See the NOTICE file distributed with


# this work for additional information regarding copyright ownership.


# The ASF licenses this file to You under the Apache License, Version 2.0


# (the"License"); you may not use this file except in compliance with


# the License. You may obtain a copy of the License at


#


# http://www.apache.org/licenses/LICENSE-2.0


#


# Unless required by applicable law or agreed to in writing, software


# distributed under the License is distributed on an"AS IS" BASIS,


# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.


# See the License for the specific language governing permissions and


# limitations under the License.


#


#


# envvars-std - default environment variables for apachectl


#


# This file is generated from envvars-std.in


#


#if test"x$LD_LIBRARY_PATH" !="x" ; then


# LD_LIBRARY_PATH="/apache24/lib:$LD_LIBRARY_PATH"


#else


# LD_LIBRARY_PATH="/apache24/lib"


#fi


#export LD_LIBRARY_PATH


#



==userX-fpm-pool.conf==


[userX]


user = userX


group = userX


listen = 127.0.0.1:9003


clear_env = yes


env['LD_LIBRARY_PATH'] = /fakepath



root@instance:/apache24/bin# ./apachectl stop && ./apachectl start



curl -H"Host: userX.xxxxxx.com" http://127.0.0.1


Array


(


)


Array


(


 [LD_LIBRARY_PATH] => /fakepath


 [USER] => userX


 [HOME] => /home


 [SCRIPT_NAME] => /index.php


 [REQUEST_URI] => /


 [QUERY_STRING] =>


 [REQUEST_METHOD] => GET


 [SERVER_PROTOCOL] => HTTP/1.1


 [GATEWAY_INTERFACE] => CGI/1.1


 [REMOTE_PORT] => 49348


 [SCRIPT_FILENAME] => //index.php


 [SERVER_ADMIN] => webmaster@localhost


 [CONTEXT_DOCUMENT_ROOT] => /userX/home/www


 [CONTEXT_PREFIX] =>


 [REQUEST_SCHEME] => http


 [DOCUMENT_ROOT] => /userX/home/www


 [REMOTE_ADDR] => 127.0.0.1


 [SERVER_PORT] => 80


 [SERVER_ADDR] => 127.0.0.1


 [SERVER_NAME] => userX.xxxxxx.com


 [SERVER_SOFTWARE] => Apache/2.4.43 (Unix) OpenSSL/1.1.1 PHP/7.4.4


 [SERVER_SIGNATURE] =>


 [PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games


 [HTTP_ACCEPT] => */*


 [HTTP_USER_AGENT] => curl/7.58.0


 [HTTP_HOST] => userX.xxxxxx.com


 [FCGI_ROLE] => RESPONDER


 [PHP_SELF] => /index.php


 [REQUEST_TIME_FLOAT] => 1587866614.9455


 [REQUEST_TIME] => 1587866614


)





Where  Unset  
相关文章