Skip to content

Commit

Permalink
修改上传文件大小限制 for docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed Aug 22, 2019
1 parent ee6517b commit d8fc6a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-av
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf

RUN echo "memory_limit=-1" > "$PHP_INI_DIR/conf.d/memory-limit.ini" \
&& echo "date.timezone=${PHP_TIMEZONE:-UTC}" > "$PHP_INI_DIR/conf.d/date_timezone.ini"
&& echo "date.timezone=${PHP_TIMEZONE:-UTC}" > "$PHP_INI_DIR/conf.d/date_timezone.ini" \
&& echo "upload_max_filesize = 100M\npost_max_size = 0" > "$PHP_INI_DIR/conf.d/upload-limit.ini"

RUN apt-get update && apt-get install -y \
libfreetype6-dev \
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ server {
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

client_max_body_size 120M;

location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$query_string;
Expand Down
1 change: 1 addition & 0 deletions public/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
</IfModule>

RewriteEngine On
LimitRequestBody 0

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
Expand Down
13 changes: 13 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ composer 会在在项目目录中创建 **vender** 目录,其中包含了项
$table->increments('id');
```

4. 默认上传文件大小限制为 2M,这个限制并不是 Wizard 自身的限制,而是运行环境的限制,如何提高上传文件大小限制呢?

首先需要修改 PHP 的配置文件 `php.ini`,修改以下两行

; 上传文件大小限制
upload_max_filesize = 100M
; 表单提交大小限制,必须大于 upload_max_filesize,或者可以设置为 0,不做任何限制
post_max_size = 0

然后,根据 web 服务器的不同进行修改

- **nginx**: 在 nginx 配置中添加 `client_max_body_size 120M;` 来指定最大 body 大小,可以参考 `docker-compose/nginx.conf` 的配置
- **apache**:修改 Wizard 目录 `public/.htaccess` 文件中 `LimitRequestBody 0` 选项的值即可,默认为0表示不限制(默认已经修改过)

## Stargazers over time

Expand Down

0 comments on commit d8fc6a3

Please sign in to comment.