Reputation: 1
I want to use phpmyadmin by this git. https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin
but I have to change max_file_uploads in php.ini.
Any ideas how to solve this?
Sorry for my bad English.
Upvotes: 0
Views: 1318
Reputation: 15041
PHP is quite flexible in how you configure it. There are several ways to change php.ini settings. Here's what I recommend for the PHP build pack.
The easiest way to change php.ini
settings for a PHP application deployed to CF is to use PHP's per-directory settings.
To do this, you can just drop a file named .user.ini
into the root of your PHP files. 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. 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.
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. See the PHP docs for more details.
This option will work for any php.ini
setting that's not marked as PHP_INI_SYSTEM.
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.
First create the folder .bp-config/php/conf.d
in the root of your project. 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). 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
. This will instruct PHP to look for additional INI configuration in the directory that we just created.
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.
Push your application to Cloud Foundry and it should pick up the new configuration options.
The benefit of both of these approaches is that your .user.ini
file only needs to set the options that you care about. 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.
There's two reasons I don't recommend overriding everything.
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.
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.
Upvotes: 2
Reputation: 4590
Here is what you have to do:
1) First follow the instructions in the README to install PHPMyAdmin:
https://github.com/dmikusa-pivotal/cf-ex-phpmyadmin
2) In your application folder under .bp-config directory create a php sub-directory
3) Copy default php.ini to the php sub-directory. The default file is located here
4) Edit local php.ini and change max_file_uploads to 180
5) Push your application using cf command line
6) Check if max_file_uploads was properly updated:
# cf files <your app name> app/php/etc/php.ini | grep max_file_uploads
You can get more details here.
Upvotes: 1