Docker:PhpMyAdmin的上传限制为2048KiB

rm5edbpk  于 2022-11-09  发布在  PHP
关注(0)|答案(8)|浏览(288)

我有一个docker-compose.yml,它看起来像这样:

webserver:
  build: ./_docker/php
  ports:
    - 80:80
  links:
    - mysql
  volumes_from:
    - app

mysql:
  image: mysql:5.7
  environment:
    MYSQL_DATABASE: "${DB_NAME}"
    MYSQL_USER: "${DB_USER}"
    MYSQL_ROOT_PASSWORD: "${DB_ROOT_PW}"
    MYSQL_PASSWORD: "${DB_PW}"
  volumes:
    - ./_docker/data/db:/docker-entrypoint-initdb.d
  volumes_from:
    - data

data:
  image: mysql:5.7
  volumes:
    - /var/lib/mysql
  command: "true"

phpmyadmin:
  image: phpmyadmin/phpmyadmin
  ports:
    - 8080:80
  links:
    - mysql
  environment:
    PMA_HOST: mysql

app:
  image: tianon/true
  volumes:
    - .:/var/www/public_html

Dockerfile看起来像这样:

FROM php:7.0-apache

# php:7.2.2-apache

# php:5.6.33-apache

COPY php.ini /usr/local/etc/php/

COPY 000-default.conf /etc/apache2/sites-available/

RUN a2enmod rewrite
RUN a2enmod expires
RUN a2enmod headers

RUN apt-get update
RUN apt-get install -y zlib1g-dev libxml2-dev libfreetype6-dev libjpeg62-turbo-dev libmcrypt-dev libpng12.0 imagemagick
RUN docker-php-ext-install mysqli zip soap
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/
RUN docker-php-ext-install gd

# Install opcache

RUN docker-php-ext-install opcache

和phpini如下:

max_input_vars = 1500
max_execution_time = 300
post_max_size=50M
upload_max_filesize=50M

当我启动容器时,我的Web服务器位于http://localhost上。
我把一个index.php和一个phpinfo();放在里面,它显示,php.ini工作。
当我打开http://localhost:8080并登录到PMA时,它显示我的上传限制设置为2048 KiB。
我可以在哪里换这个?
提前感谢!

up9lanfz

up9lanfz1#

在docker中像这样使用UPLOAD_LIMIT env。这来自我的docker-compose. yml。UPLOAD_LIMIT的默认值是2048 K,也就是2048 KiB。将值设置为300 M会将其增加到300 MiB。
参考:https://github.com/phpmyadmin/docker#environment-variables-summary

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: 'php7.3-phpmyadmin'
    restart: 'always'
    links:
      - mysql
    environment:
      PMA_HOST: mysql
      PMA_PORT: 3306
      UPLOAD_LIMIT: 300M
    ports:
      - '8082:80'
    volumes:
      - /sessions
2nc8po8w

2nc8po8w2#

我在中实现了UPLOAD_LIMIT ENV变量
https://github.com/phpmyadmin/docker/pull/261/files#diff-80edf79b0f382a3c6e871ac209ffd6abR57

j1dl9f46

j1dl9f463#

您需要在enviroment中使用UPLOAD_LIMIT,并且需要使用=符号指定值,例如:UPLOAD_LIMIT=300M

version: '3.1'
services:
  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somerandompasswordgenerated
    ports:
      - 3306:3306

  phpmyadmin:
    image: phpmyadmin
    restart: always
    ports:
      - 8080:80
    environment:
      - PMA_ARBITRARY=1
      - UPLOAD_LIMIT=300M
envsm3lx

envsm3lx4#

在我的例子中,我无法使用UPLOAD_LIMIT修复它,因此在没有进一步调试的情况下,我需要一个快速的解决方案,即使它是临时的:
1.打开phpmyadmin容器终端:docker exec -it container_name bash
1.如果你没有vim或nano编辑器安装一个:apt-get updateapt-get install vim
1.创建配置文件:vi /usr/local/php/conf.d/myconf.ini
1.具有以下内容:post_max_size=50Mupload_max_filesize=50M
1.重新启动容器

请记住这些更改将在重新创建容器时消失,这只是一个临时解决方案。请尝试按照上一个答案中的建议使用UPLOAD_LIMIT。
UPDATE再次尝试设置upload_limit环境,但仍然没有成功,因此找到了另一个解决方案:创建了一个包含以下内容的文件uploads.ini

post_max_size=50M 
upload_max_filesize=50M

并将其链接到容器体积:

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    links: 
      - mysql:db
    ports:
      - 8084:80
    volumes:
      - ./uploads.ini:/usr/local/etc/php/conf.d/php-phpmyadmin.ini
    environment:
      MYSQL_ROOT_PASSWORD: something
      #UPLOAD_LIMIT: 3000000000 <-- didn't work
waxmsbnn

waxmsbnn5#

下面的代码运行得很好。我的docker-compose.yml包含以下代码:

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: some-name
    env_file:
      - phpmyadmin.env
    depends_on:
      - mariadb
    volumes:

下面的条目被添加到phpmyadmin.env中:UPLOAD_LIMIT= 256 MB较大的数字(最大值:256 MiB)在集装箱被放下后立即出现,并再次恢复。

sd2nnvve

sd2nnvve6#

如果你想从phpmyadmin docker镜像安装并运行docker,你可以执行这个命令。
“上传限制=256M”phpmyadmin
这对我来说很有效,可以上传到256MB的SQL文件。

z31licg0

z31licg07#

上传限制:5亿美元

mariadb:
    image: mariadb:latest
    container_name: w-mariadb
    restart: always
    ports:
      - "3307:3306"
    environment:
      MYSQL_DATABASE: db_name
      MYSQL_USER: root
      MYSQL_PASSWORD: db_password
      MYSQL_ROOT_PASSWORD: db_password
    volumes:
      - 'w-mariadb:/var/lib/mysql'
    networks:
      - w-network
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: w-phpmyadmin
    links:
      - mariadb
    environment:
      MYSQL_ROOT_PASSWORD: db_password
      PMA_HOST: mariadb
      UPLOAD_LIMIT: 500M
    restart: always
    ports:
      - '8383:80'
    networks:
      - w-network
ymzxtsji

ymzxtsji8#

我编辑此文件:

/usr/local/etc/php/conf.d/phpmyadmin-misc.ini

并设置新值:

post_max_size=64M
upload_max_filesize=64M

它工作正常。

相关问题