I built WordPress with Docker.
At that time, the file upload limit (upload_max_filesize, post_max_size) was different between the production and virtual environment, so I wrote the flow of changing php.ini.
Log in to Docker.
First, find out the name of the service.
As we are using Docker compose, the following command will display the SERVICE.
$ docker-compose ps
Login to Docker by passing the SERVICE name obtained here.
exec is used to execute a new command in an existing container.
-it allows interactive manipulation of the command.
/bin/bash can be added to specify the command to be executed within the container.
$ docker-compose exec -it [SERVICE NAME] /bin/bash
Location of php.ini
I forget where php.ini is every time. The command I often see is grep, but it’s useful to type php –ini to see the Path.
$ php --ini
Editing php.ini
ls, you will see that php.ini-development and php.ini-production exist.
These are template files containing the recommended settings for the respective environment.
You can use either php.ini-development or php.ini-production as a base, copy it and rename it to php.ini. If you want to see the logs during development, copy php.ini-development.
$ cp php.ini-development php.ini
Edit the created php.ini to change the file upload restrictions.
$ vi php.ini
If the vi command is not available, install it.
$ apt-get update
$ apt-get install vim
In php.ini, update the respective values for upload_max_filesize and post_max_size.
To change from 2MB to 10MB, save the following.
upload_max_filesize = 10MB
post_max_size = 10MB
Exit from Docker by hitting the command.
$ exit
Restart Docker.
For Docker, php.ini is loaded when the container is started, so restarting Docker will reflect this.
It is easier to restart from the application, but here is the command in case you need it.
$ docker-compose restart [SERVICE NAME]
Incidentally, Apache is usually restarted to reflect this, but the commands are different for each operating system, so check the operating system first.
$ cat /etc/os-release
Then, depending on the operating system, the Apache restart command can be hit to reflect this.
The following is the case for Debian.
$ service apache2 restart