简体   繁体   English

如何在IBM Bluemix上更改php.ini

[英]How to change php.ini on ibm bluemix

I want to use phpmyadmin by this git. 我想通过此git使用phpmyadmin。 https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin

but I have to change max_file_uploads in php.ini. 但我必须在php.ini中更改max_file_uploads。

Any ideas how to solve this? 任何想法如何解决这个问题?

Sorry for my bad English. 对不起,我的英语不好。

PHP is quite flexible in how you configure it. PHP在配置方面非常灵活。 There are several ways to change php.ini settings. 有几种更改php.ini设置的方法。 Here's what I recommend for the PHP build pack. 这是我对PHP构建包的建议。

  1. The easiest way to change php.ini settings for a PHP application deployed to CF is to use PHP's per-directory settings . 更改已部署到CF的PHP应用程序的php.ini设置的最简单方法是使用PHP的按目录设置

    To do this, you can just drop a file named .user.ini into the root of your PHP files. 为此,您只需将名为.user.ini的文件.user.ini到PHP文件的根目录中。 In the case of the PHPMyAdmin app you referenced, you'd put it in the htdocs directory, since this is where all the application files are installed. 对于您引用的PHPMyAdmin应用程序,将其放置在htdocs目录中,因为这是所有应用程序文件的安装位置。 Set whatever options you need to adjust in that file. 在该文件中设置您需要调整的任何选项。

    Push your application to Cloud Foundry and it should pick up the new configuration options. 将您的应用程序推送到Cloud Foundry,它将选择新的配置选项。

    Side note, you can put the .user.ini file in other directories too, exactly where you put it depends on the scope of where you want the settings contained in that file to be applied. 旁注,您也可以将.user.ini文件放置在其他目录中,确切放置位置取决于希望应用该文件中包含的设置的范围。 See the PHP docs for more details. 有关更多详细信息,请参见PHP文档

    This option will work for any php.ini setting that's not marked as PHP_INI_SYSTEM . 此选项适用于任何未标记为PHP_INI_SYSTEM的 php.ini设置。

  2. If the setting you want to change is marked as PHP_INI_SYSTEM or if you want to change php.ini settings during staging (for example, to affect the options used by Composer) then you need to use this option. 如果要将要更改的设置标记为PHP_INI_SYSTEM,或者如果要在登台期间更改php.ini设置(例如,影响Composer使用的选项),则需要使用此选项。

    First create the folder .bp-config/php/conf.d in the root of your project. 首先在项目的根目录中创建文件夹.bp-config/php/conf.d Then add a file with the .ini extension into that directory, ex: my-settings.ini (side note, you can add multiple .ini files to this directory). 然后将扩展名为.ini的文件添加到该目录中,例如:my-settings.ini(注意,您可以将多个.ini文件添加到该目录中)。 Set whatever options you need to adjust in it. 设置需要调整的任何选项。

    Second set the environment variable PHP_INI_SCAN_DIR for for your application to .bp-config/php/conf.d . 其次,为您的应用程序将环境变量PHP_INI_SCAN_DIR设置为.bp-config/php/conf.d This will instruct PHP to look for additional INI configuration in the directory that we just created. 这将指示PHP在我们刚创建的目录中查找其他INI配置。

    You can set the environment variable by running cf set-env app-name 'PHP_INI_SCAN_DIR' '.bp-config/php/conf.d' or by adding it to the env block of your manifest.yml file. 您可以通过运行cf set-env app-name 'PHP_INI_SCAN_DIR' '.bp-config/php/conf.d'或将其添加到manifest.yml文件的env块来设置环境变量。

    Push your application to Cloud Foundry and it should pick up the new configuration options. 将您的应用程序推送到Cloud Foundry,它将选择新的配置选项。

The benefit of both of these approaches is that your .user.ini file only needs to set the options that you care about. 这两种方法的好处是您的.user.ini文件仅需要设置您关心的选项。 The option that Alex mentioned in his answer will technically work, but if you do that you will override all of the default php.ini settings that are provided by the build pack. Alex在他的答案中提到的选项在技术上会起作用,但是如果您这样做,您将覆盖构建包提供的所有默认php.ini设置。

There's two reasons I don't recommend overriding everything. 我不建议您覆盖所有内容,这有两个原因。

  1. You now have the complete configuration file in your app and if we change anything in the build pack, your configuration will get out-of-sync and your app could fail to stage the next time you push it. 现在,您的应用程序中具有完整的配置文件,如果我们在构建包中进行了任何更改,您的配置将不同步,下次您推送该应用程序时,它可能无法上演。

  2. If you're not very careful you can break things. 如果您不太小心,则可能会破坏事情。 This is one of the most common things I see people doing with PHP apps that causes an application to fail, more specifically it causes the PHP extensions to not load which in turn causes the app fail. 这是我看到人们使用PHP应用程序执行的最常见的事情之一,导致应用程序失败,更具体地说,它导致PHP扩展无法加载,进而导致应用程序失败。

Here is what you have to do: 这是您要做的:

1) First follow the instructions in the README to install PHPMyAdmin: 1)首先按照自述文件中的说明安装PHPMyAdmin:

https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin

2) In your application folder under .bp-config directory create a php sub-directory 2)在.bp-config目录下的应用程序文件夹中,创建一个php子目录

3) Copy default php.ini to the php sub-directory. 3)将默认的php.ini复制到php子目录。 The default file is located here 默认文件位于此处

4) Edit local php.ini and change max_file_uploads to 180 4)编辑本地php.ini并将max_file_uploads更改为180

5) Push your application using cf command line 5)使用cf命令行推送您的应用程序

6) Check if max_file_uploads was properly updated: 6)检查max_file_uploads是否已正确更新:

# cf files <your app name> app/php/etc/php.ini | grep max_file_uploads

You can get more details here . 您可以在此处获得更多详细信息。

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

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