简体   繁体   English

通过自动化脚本找到PHP.ini

[英]Find PHP.ini through automated script

We have built special extension for PHP.我们为 PHP 构建了特殊的扩展。 It can be deployed on RHEL, Ubuntu & Windows OS including containers.它可以部署在 RHEL、Ubuntu 和 Windows 操作系统上,包括容器。 We would like to give liberty to the user so that, s/he can enable the extension on need basis by executing simple scripts.我们想给用户自由,以便她/他可以通过执行简单的脚本根据需要启用扩展。 We are exploring the possibilities to build the automated script to add extension entry into the respective php.ini.我们正在探索构建自动化脚本以将扩展条目添加到相应的 php.ini 的可能性。

There are many permutations to find the ini file, because PHP application can be hosted on various servers like apache, nginx & IIS.查找 ini 文件有多种排列方式,因为 PHP 应用程序可以托管在各种服务器上,例如 apache、ZEE434023CF89D7DFB21F63D64F0F9D74B27DA5ACF846261。 Addition to that, each website can point to different PHP version.除此之外,每个网站可以指向不同的 PHP 版本。 Some sever has multiple modes, for example Apache has modes like prefork, php-fpm, etc. We can have multiple websites hosted on those servers with different settings and poiting to differnt PHP versions.一些服务器有多种模式,例如 Apache 有 prefork、php-fpm 等模式。我们可以在这些服务器上托管多个网站,具有不同的设置并指向不同的 PHP 版本。

We need to find the appropriate php.ini to add the extension entry.我们需要找到合适的 php.ini 来添加扩展条目。 How can we find the appropriate php.ini for the given website hosted on any server?我们如何为托管在任何服务器上的给定网站找到合适的 php.ini?

I know we can run php -i in command prompt.我知道我们可以在命令提示符下运行php -i This will give php.ini location for PHP CLI.这将为 PHP CLI 提供 php.ini 位置。 But, webserver may be pointing to different php.ini.但是,网络服务器可能指向不同的 php.ini。

Other option could be to create simple info.php with <?php phpinfo(); ?>其他选项可能是创建简单的 info.php 和<?php phpinfo(); ?> <?php phpinfo(); ?> and access it into browser. <?php phpinfo(); ?>并在浏览器中访问它。 But, it's manual process.但是,这是手动过程。 I want to automate it using some script.我想使用一些脚本来自动化它。

Any help would be appreciated.任何帮助,将不胜感激。 Thanks in advance.提前致谢。

If you're looking for a bash script or a command to find any "php.ini" file on your server, you can use如果您正在寻找 bash 脚本或在您的服务器上查找任何“php.ini”文件的命令,您可以使用

find / -type f -name "php.ini"

or you can change "/" to a subfolder from which start searching.或者您可以将“/”更改为开始搜索的子文件夹。

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

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