Solution for 413 request entity too large on PHP & Nginx Server

on /etc/nginx/nginx.conf add the following line to server or location or http context to increase the size limit.

client_max_body_size 200M;

 

http {
.....
      client_max_body_size 200M;
.....       
}

 

On /etc/php.ini search the line and set the following directives

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M

;The maximum size of an uploaded file.
upload_max_filesize = 200M

;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 30M

 

Restart or reload your php and nginx server.

service nginx restart
service php-fpm restart

Tes Performa Server Menggunakan Apache Benchmarking

ab -c 1 -n 100 https://www.antorij.com/

[antorij@antorij-centos6 ~]$ ab -c 1 -n 100 https://www.antorij.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, zeustech.net/
Licensed to The Apache Software Foundation, apache.org/

Benchmarking localhost (be patient).....done

Server Software:        Nginx
Server Hostname:        localhost
Server Port:            80

Document Path:          /
Document Length:        31698 bytes

Concurrency Level:      1
Time taken for tests:   26.170 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      3190000 bytes
HTML transferred:       3169800 bytes
Requests per second:    3.82 [#/sec] (mean)
Time per request:       261.701 [ms] (mean)
Time per request:       261.701 [ms] (mean, across all concurrent requests)
Transfer rate:          119.04 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   248  262  11.8    260     324
Waiting:      201  214  11.7    211     276
Total:        248  262  11.8    260     324

Percentage of the requests served within a certain time (ms)
  50%    260
  66%    263
  75%    265
  80%    265
  90%    269
  95%    276
  98%    310
  99%    324
 100%    324 (longest request)
[antorij@antorij-centos6 ~]$
1 2 3 4