Docker Community Forums

Share and learn in the Docker community.

How to get access to php.ini file

Hi @gforghetti

The added data to the YAML file is not sufficient, as the new limit for uploads set as

RUN touch /usr/local/etc/php/conf.d/uploads.ini \
    && echo "upload_max_filesize = 10M;" >> /usr/local/etc/php/conf.d/uploads.ini

which you introduced above is not taking care of the /usr/local/etc/php/conf.d folder.

Note that I am not nitpicking here - my intent is to finish this discussion in a way that will provide the good solution for anyone who decides to use Docker to install wordpress.

Try increasing the value to what you think you want the maximum to be for your Wordpress site.
Below is for 1024M. I’m pretty sure the value has to be in megabytes.

upload_max_filesize = 1024M

I believe that you misunderstood my today’s remark, so I will restate it this way: the file
/usr/local/etc/php/conf.d/uploads.ini should also be persisted the same way as the folder /var/www/html

Making sense?

I think for the /usr/local/etc/php directory, the better wording is to have it exposed as a volume so you can do a bind mount and specify overrides. Nothing in that directory is modified at run time so no need for you to define it on an external volume and make it persistent.

You can open a GitHub issue here -> https://github.com/docker-library/wordpress/issues

Tell them you want the Docker Official Wordpress Docker Image to expose the /usr/local/etc/php directory as a volume mount point so you (and other users) can bind mount your own customization files at container run time.

Very good observation (Nothing in that directory is modified at run time), @gforghetti :clap:

I stand corrected and grateful for your time spent helping me to resolve my problem. The good side-effect is that this solution will help many other folks that undoubtedly follow.

I created this issue at the suggested GitHub repo and will update this thread once that issue gets resolved.

The final thread with the solution in the form of the YAML file for the composer is here.

Yes, that looks good and no need for you to build a custom docker image. I had tried that previously and it did not work for me. I probably had a typo on the target side of the mount.

I’ll give that a try myself.

@monterey

Hi, I tried the solution that was identified in the GitHub Issue response and it worked for me too.

:smile:

@gforghetti can you do a little magic and make the reference to this solution appear in the original article (https://docs.docker.com/compose/wordpress/) that led me to get in touch with you and then with the wordpress library folks at https://github.com/docker-library/wordpress/issues/375 ?

Find the PHP.ini file in root directory.If you not see the file select the option “Show hidden files” then the PHP.ini file will be visible. After that add this code in PHP.ini

upload_max_filesize = 20M
post_max_size = 25M
memory_limit = 30M

Also edit .htaccess file and add this code

php_value upload_max_filesize 20MB
php_value post_max_size 25MB
php_value memory_limit 30MB

Another method is to modify the WordPress file wp-config.php or functions.php files, and paste the following lines of code

@ini_set( ‘upload_max_size’ , ’20MB’ );
@ini_set( ‘post_max_size’, ’25MB’);
@ini_set( ‘memory_limit’, ’30MB’ );

If you still having an issue I will refer you to a guide where you ca easily learn how to increase upload size limit

Hi gary use this docker-compose.yml file and in same folder create two folder with name “database” and “html” and one file name “uploads.ini”
fire up the compose file

#####################################################################################
version: ‘3.3’

services:

wordpress:

 depends_on:

   - db

 image: wordpress:latest

 volumes:

   - ./html:/var/www/html

   - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini

 ports:

   - "80:80"

 restart: always

 environment:

   WORDPRESS_DB_HOST: db:3306

   WORDPRESS_DB_USER: wordpress

   WORDPRESS_DB_PASSWORD: wordpress

db:

 image: mysql:5.7

 volumes:

   - ./database:/var/lib/mysql

 restart: always

 ports:

   - 3306:3306

 environment:

   MYSQL_ROOT_PASSWORD: wordpress

   MYSQL_DATABASE: wordpress

   MYSQL_USER: wordpress

   MYSQL_PASSWORD: wordpress

phpmyadmin:

 image: phpmyadmin/phpmyadmin

 depends_on:

   - db

 restart: always

 ports:

   - 3333:80

 environment:

   PMA_HOST: db

   MYSQL_ROOT_PASSWORT: wordpress  

 volumes:

   - ./uploads.ini:/usr/local/etc/php/conf.d/php-phpmyadmin.ini

########################################################

my uploads.ini file look like that…

file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600
max_file_uploads = 50000
max_execution_time = 5000
max_input_time = 5000

I added php.ini inside my wordpress folder and it worked.

    upload_max_filesize = 256M
    post_max_size = 256M
    memory_limit = 256M