个性化阅读
专注于IT技术分析

WordPress的Docker不会增加上传限制

我正在尝试将Dockerized WordPress实例的上传限制创建为150M。

[文件名]超出了此网站的最大上传大小。

我创建了一个uploads.ini文件, 并按卷将其附加到实例。但是我仍然无法让Wordpress媒体上传器增加它的限制。

Docker-compose.yml:

version: '2'
services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: password1
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: password1

   wordpress:
     depends_on:
       - db
     build: ./wordpress
     ports:
       - "8085:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_PASSWORD: password1
     volumes: 
       - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini 
volumes:
    db_data:

uploads.ini:

file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600

Docker检查容器:

[
    {
        "Id": "8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f", "Created": "2017-03-15T23:47:54.480206792Z", "Path": "docker-entrypoint.sh", "Args": [
            "apache2-foreground"
        ], "State": {
            "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 15956, "ExitCode": 0, "Error": "", "StartedAt": "2017-03-16T17:46:30.075247017Z", "FinishedAt": "2017-03-16T17:46:29.700791339Z"
        }, "Image": "sha256:cfe94722592e66629527d7fc1546174916c758c6945eb9911506077e76c4d00e", "ResolvConfPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/resolv.conf", "HostnamePath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/hostname", "HostsPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/hosts", "LogPath": "/var/lib/docker/containers/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f/8edc91a51bf8480edc927de2fa5c16624ac43a7beb58c109cd771a143f67746f-json.log", "Name": "/edgeofrevolt_wordpress_1", "RestartCount": 0, "Driver": "aufs", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": [
            "8efe40659ebd3e44b17d45f1dd2aac20f12e13a4513e41520d6c2a1b1f01aa08"
        ], "HostConfig": {
            "Binds": [
                "/root/NginxDockerProxyPass/edgeofrevolt/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini:rw", "374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53:/var/www/html:rw"
            ], "ContainerIDFile": "", "LogConfig": {
                "Type": "json-file", "Config": {}
            }, "NetworkMode": "edgeofrevolt_default", "PortBindings": {
                "80/tcp": [
                    {
                        "HostIp": "", "HostPort": "8085"
                    }
                ]
            }, "RestartPolicy": {
                "Name": "always", "MaximumRetryCount": 0
            }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": [], "CapAdd": null, "CapDrop": null, "Dns": null, "DnsOptions": null, "DnsSearch": null, "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [
                0, 0
            ], "Isolation": "", "CpuShares": 0, "Memory": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": -1, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0
        }, "GraphDriver": {
            "Name": "aufs", "Data": null
        }, "Mounts": [
            {
                "Source": "/root/NginxDockerProxyPass/edgeofrevolt/uploads.ini", "Destination": "/usr/local/etc/php/conf.d/uploads.ini", "Mode": "rw", "RW": true, "Propagation": "rprivate"
            }, {
                "Name": "374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53", "Source": "/var/lib/docker/volumes/374db2645434a23b92074b6d95935361948397519f2d5a531986bb925ceb0f53/_data", "Destination": "/var/www/html", "Driver": "local", "Mode": "rw", "RW": true, "Propagation": "rprivate"
            }
        ], "Config": {
            "Hostname": "8edc91a51bf8", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": {
                "80/tcp": {}
            }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [
                "affinity:container==6797730d5702955f114fd260628b82615aa7702d0cafae7dae456b1806009437", "WORDPRESS_DB_HOST=db:3306", "WORDPRESS_DB_PASSWORD=p0kem0n2468Y", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "PHPIZE_DEPS=autoconf \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkg-config \t\tre2c", "PHP_INI_DIR=/usr/local/etc/php", "APACHE_CONFDIR=/etc/apache2", "APACHE_ENVVARS=/etc/apache2/envvars", "PHP_EXTRA_BUILD_DEPS=apache2-dev", "PHP_EXTRA_CONFIGURE_ARGS=--with-apxs2", "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2", "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2", "PHP_LDFLAGS=-Wl, -O1 -Wl, --hash-style=both -pie", "GPG_KEYS=0BD78B5F97500D450838F95DFE857D9A90D90EC1 6E4F6AB321FDC07F2C332E3AC2BF0BC433CFC8B3", "PHP_VERSION=5.6.30", "PHP_URL=https://secure.php.net/get/php-5.6.30.tar.xz/from/this/mirror", "PHP_ASC_URL=https://secure.php.net/get/php-5.6.30.tar.xz.asc/from/this/mirror", "PHP_SHA256=a363185c786432f75e3c7ff956b49c3369c3f6906a6b10459f8d1ddc22f70805", "PHP_MD5=68753955a8964ae49064c6424f81eb3e", "WORDPRESS_VERSION=4.7.2", "WORDPRESS_SHA1=7b687f1af589c337124e6247229af209ec1d52c3"
            ], "Cmd": [
                "apache2-foreground"
            ], "Image": "edgeofrevolt_wordpress", "Volumes": {
                "/usr/local/etc/php/conf.d/uploads.ini": {}, "/var/www/html": {}
            }, "WorkingDir": "/var/www/html", "Entrypoint": [
                "docker-entrypoint.sh"
            ], "OnBuild": null, "Labels": {
                "com.docker.compose.config-hash": "da7c1855141bc762874ddd4734f2b062556a041750ff48a3cfa3954bb7dfed6c", "com.docker.compose.container-number": "1", "com.docker.compose.oneoff": "False", "com.docker.compose.project": "edgeofrevolt", "com.docker.compose.service": "wordpress", "com.docker.compose.version": "1.8.1"
            }
        }, "NetworkSettings": {
            "Bridge": "", "SandboxID": "ceec8d1498a6988b4cc56ad10afa5cf87e0670d030460efbd26bd5ace185a375", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {
                "80/tcp": [
                    {
                        "HostIp": "0.0.0.0", "HostPort": "8085"
                    }
                ]
            }, "SandboxKey": "/var/run/docker/netns/ceec8d1498a6", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": {
                "edgeofrevolt_default": {
                    "IPAMConfig": null, "Links": null, "Aliases": [
                        "wordpress", "8edc91a51bf8"
                    ], "NetworkID": "89bde3d402cc2fe938279c30415cc2947f92205e610dff1acba69101440b90e7", "EndpointID": "916db2fab99a1637aef87aa1f05fb702fb9b6d3692bf04a9bf46bf122fe9e990", "Gateway": "172.23.0.1", "IPAddress": "172.23.0.3", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:17:00:03"
                }
            }
        }
    }
]

编辑:” upload_max_filesize”中有错字


#1


我发现了我的问题。

docker-compose kill将杀死一个容器, 但会从缓存中对其进行重建。意味着我的文件没有任何更改。

使用docker-compose up -d –build


#2


它对我的工作如下:我在本地目录(.yml文件所在的位置)中创建了uploads.ini, 并包含以下几行。这正是拳头中所说的。

file_uploads = On
memory_limit = 500M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 600

之后, 我添加了

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

到我的.yml文件, 如第一篇文章中所述。

在此之后, 我不得不删除容器/图像(基本上从头开始):

docker stop [image name]
docker rm [image name]
docker image rm [image name]

在某些地方, 我最终使用了由图像名称插入的ID。名称或ID基本上, 你必须停止, 删除容器和图像。底线是从头开始, 在你的.yml文件中有其他行, 如第一篇文章中所述。记住, 你将失去所有wp工作。现在运行

docker-compose up -d --build

现在应该增加上传限制。进行此更改后, 我可以上传新的更大主题。没有更多的上传文件大小错误。唯一的问题是, 如果你需要在工作中间增加此上传大小限制, 那么你将如何做呢?…


#3


你的uploads.ini中有一个错字

upload_max_fileszie => upload_max_filesize


#4


获取容器的ID

`sudo docker container ls --filter name='_wordpress'`

`ID=input_container_ID`

apt-get更新容器

`sudo docker container exec -it $ID bash -c "apt-get update"`

apt-get在容器中安装nano

`sudo docker container exec -it $ID bash -c "apt-get install nano"`

纳米编辑uploads.ini并粘贴:

`
file_uploads = On
memory_limit = 128M
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 600
`

`sudo docker container exec -it $ID bash -c "nano /usr/local/etc/php/conf.d/uploads.ini"`

停止/启动docker-compose:

`CTRL + C`

`sudo docker-compose up`
赞(5)
未经允许不得转载:srcmini » WordPress的Docker不会增加上传限制

评论 抢沙发

评论前必须登录!