1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

アップロードファイルの制限修正【GCP for KUSANAGI Business】

Last updated at Posted at 2020-05-08

アップロードファイルの制限を修正する方法

KUSANAGI環境のファイルアップロード制限を変更するには、サーバーにログインしてroot権限にて設定を書き換える必要があります。

root権限への移行

GCPの管理画面からSSHで入り、Root権限に移行します。

[test@test-vm ~]$ sudo su -
[root@test-vm ~]#

PHP 設定ファイルの変更

ドメインディレクトリに移動して PHP 設定ファイルを作成します。
以下の your_provision は KUSANAGI で設定したプロビジョンです。

[root@test-vm ~]# cd /home/kusanagi/your_provision/DocumentRoot/
[root@test-vm ~]# vi .user.ini

そして、PHP 設定ファイルに必要な容量を以下のように設定します。

memory_limit = 900M
post_max_size = 500M
upload_max_filesize = 500M

キーボードの「Esc」を押して、コマンドモードに戻ります。
「:wq [Enter]」を押して、保存終了します。

Nginx のアップロード制限変更

[root@test-vm ~]# cd /etc/nginx/conf.d

そして、 your_provision_http.conf と your_provision_ssl.conf (SSl時)を、viコマンドで変更します。
your_provision は KUSANAGI で設定したプロビジョンです。

your_provision_http.conf の変更

[root@test-vm ~]# vi your_provision_http.conf

編集画面で編集をします。修正する場所を探すために「/client_max_body_size」を入力して、 client_max_body_size を検索します。
そして、以下のように修正します。

修正前(デフォルト設定):16Mになっているはずです。(ここでは13行目)

 12     charset UTF-8;
 13     client_max_body_size 16M;
 14     root  /home/kusanagi/your_provision/DocumentRoot;
 15     index index.php index.html index.htm;

修正後:500Mに設定。(ここでは13行目)

 12     charset UTF-8;
 13     client_max_body_size 500M;
 14     root  /home/kusanagi/your_provision/DocumentRoot;
 15     index index.php index.html index.htm;

your_provision_ssl.conf の変更

[root@test-vm ~]# vi your_provision_ssl.conf

your_provision_http.conf と同じように変更を行います。
編集画面で編集をします。修正する場所を探すために「/client_max_body_size」を入力して、 client_max_body_size を検索します。
そして、以下のように修正します。

修正前(デフォルト設定):16Mになっているはずです。(ここでは38行目)

 37     charset UTF-8;
 38     client_max_body_size 16M;
 39     root  /home/kusanagi/your_provision/DocumentRoot;
 40     index index.php index.html index.htm;

修正後:500Mに設定。(ここでは38行目)

 37     charset UTF-8;
 38     client_max_body_size 500M;
 39     root  /home/kusanagi/your_provision/DocumentRoot;
 40     index index.php index.html index.htm;

設定ファイルの動作確認

設定ファイルにエラーがないか確認します。

[root@test-vm ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@test-vm ~]#

上記のように表示されれば問題ありません。もし、エラーが出た場合はその英語を読んで修正する必要があります。

再起動

[root@test-vm ~]# kusanagi restart
完了しました。
[root@test-vm ~]# 

このように正常に終われば、問題ありません。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?