upload size increase not working (LAMP Docker)

huangapple go评论88阅读模式
英文:

upload size increase not working (LAMP Docker)

问题

I see you're experiencing issues with uploading large files in your Docker Compose setup. To address this problem, you've set the upload limit to 500MB in the phpmyadmin environment variables, but it's not working as expected. You're looking for guidance on resolving this issue.

你遇到了在Docker Compose设置中上传大文件的问题。为了解决这个问题,你已经在phpmyadmin的环境变量中将上传限制设置为500MB,但它没有按预期工作。你正在寻求解决此问题的指导。

To troubleshoot this, you can check the following:

要解决这个问题,你可以检查以下内容:

  1. Verify that the PHP configuration within your container reflects the desired upload limit. You can try creating a phpinfo.php file within your web server container to check PHP configuration settings.

    验证容器内的PHP配置是否反映了所需的上传限制。你可以尝试在Web服务器容器中创建一个phpinfo.php文件来检查PHP配置设置。

  2. Ensure that the phpmyadmin container is picking up the correct environment variables. Double-check the container logs or configuration to make sure it's using the expected UPLOAD_LIMIT value.

    确保phpmyadmin容器正在使用正确的环境变量。仔细检查容器日志或配置,确保它使用了预期的UPLOAD_LIMIT值。

  3. If the upload limit is not being applied, you might need to modify the PHP configuration directly. Look for the php.ini file within your PHP container and adjust the upload_max_filesize and post_max_size directives to your desired values.

    如果上传限制没有生效,你可能需要直接修改PHP配置。在你的PHP容器中查找php.ini文件,并将upload_max_filesizepost_max_size指令调整为所需的值。

  4. Make sure that any changes to the PHP configuration or environment variables are being applied correctly by restarting the containers after making the changes.

    确保在进行更改后重新启动容器以正确应用对PHP配置或环境变量的更改。

Remember to rebuild your containers after making changes to Docker Compose files or Dockerfiles. If you encounter further issues, please provide more details about any error messages or logs you're seeing for a more specific solution.

在对Docker Compose文件或Dockerfile进行更改后,记得重新构建容器。如果遇到进一步的问题,请提供更多关于任何错误消息或日志的详细信息,以便提供更具体的解决方案。

英文:

cant upload +2m files

docker compose

version: "3.7"
services:
  web-server:
    build:
      dockerfile: php.Dockerfile
      context: .
    restart: always
    volumes:
      - "./html/:/var/www/html/"
    ports:
      - "8080:80"
  mysql-server:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rise
    volumes:
      - mysql-data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    restart: always
    environment:
      PMA_HOST: mysql-server
      PMA_USER: root
      PMA_PASSWORD: rise
      UPLOAD_LIMIT: 500M
    ports:
      - "8444:80"
volumes:
  mysql-data:

Php.dockerfile

FROM php:8.0-apache

RUN a2enmod rewrite

RUN apt-get update && apt-get install -y git unzip zip


COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN install-php-extensions gd pdo_mysql bcmath zip intl opcache MySQLi

COPY --from=composer:2.0 /usr/bin/composer /usr/local/bin/composer

if you see the upload limit is 500mb but the php site dont want upload 2+mb files

follow guidens and add env but is not working.
dont finde the php.ini or the .htaccess

can you help me please

thx

答案1

得分: 0

抱歉,我只能为您提供英文到中文的翻译。以下是您要翻译的内容的中文翻译:

看起来您只将 ENV 变量添加到了 PhpAdmin 容器配置中。但是要在网站上上传文件,需要涉及到 'web-server' 容器,是吗?

所以您需要更新 'web-server' 容器的 php.ini 文件。

这可以通过将自定义的 php.ini 文件从主机映射到容器来完成。此文件中的值将覆盖任何现有的值。将以下行添加到您的 docker-compose.yml 文件中,位于 web-server 下:

volumes:
  - ./path/to/the/local/custom-php.ini:/path/to/the/folder/where/php/scans/additional/ini-files/custom-php.ini

然后创建 ./path/to/the/local/custom-php.ini(路径可以是任何的),并在其中添加以下行:

upload_max_filesize = 500M

完成后,您需要确定 /path/to/the/folder/where/php/scans/additional/ini-files/ 文件夹。可以通过运行以下命令来完成:

docker exec web-server php --ini

在输出中,您将看到 php 使用的所有 ini 文件,并且应该会有类似于 "Scan for additional .ini files in: {path to folder}" 的内容。这就是您应该映射您的 custom-php.ini 文件的文件夹,即您需要将 /path/to/the/folder/where/php/scans/additional/ini-files/ 替换为此路径。

英文:

It looks like you added ENV var to the PhpAdmin container config only. But to upload file on site, the 'web-server' container is involved instead, right?

So you need to update the php.ini file of the 'web-server' container.

This can be done by mapping custom php.ini file from host to container. Values in this file will override any existing values. Add this lines to your docker-compose.yml, under the web-server:

volumes:
  - ./path/to/the/local/custom-php.ini:/path/to/the/folder/where/php/scans/additional/ini-files/custom-php.ini

Then create ./path/to/the/local/custom-php.ini (path can be any) file and put there this line:

upload_max_filesize = 500M

After this you need to determine /path/to/the/folder/where/php/scans/additional/ini-files/ folder. This can be done by running this command:

docker exec web-server php --ini

In the output you will see all the ini files used by php, and there will should be smth like "Scan for additional .ini files in: {path to folder}". This is the folder where you should map your custom-php.ini file, i.e. you need to replace /path/to/the/folder/where/php/scans/additional/ini-files/ with this path.

huangapple
  • 本文由 发表于 2023年4月17日 22:50:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76036446.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定