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
1 Like

modify the .htaccess file
php_value upload_max_filesize 512M
php_value post_max_size 512M
it worked for me

thanks, it worked for me!

Iā€™m really newby at Docker, so I donā€™t know if the way of modifing the file is an good idea.
However for testing purposes Iā€™ve entered the container with bash and created the php.ini-File with nano to increase the upload-size (Using Bash infos: https://ligerlearn.com/how-to-edit-files-within-docker-containers/)

Get Container ID
docker ps

Open Bash:
docker exec -it CONTAINERIDXY /bin/bash

Navigate to usr/local/etc/php

Install nano
apt-get update
apt-get install nano

Create file
enter nano
add lines above

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

ctrl+o
enter Filename php.ini
ctrl+x to exit nano

Restart Conatiner and try

For just testing and trying something out, itā€™s okay. In other case, you should not do that. Bind mount a configuration file or build your own image containing that file.

1 Like

I think this is the easiest way.

  1. access : /home/your account name directory/WP installed directory/
  2. Enter the ā€˜ls -alā€™ command. Youā€™ll see the .htaccess file.
  3. nano .htaccess
  4. Enter the size you want.
php_value upload_max_filesize 512M
php_value post_max_size 1024M
  1. Ctrl+O ā†’ Enter ā†’ Ctrl+X

Done.

Hi
I ran into the same problem
The uploaded file exceeds the upload_max_filesize directive in php.ini.
How do I access the php.ini file in order to change it?
If possible a detailed explanation
Thanks