1.nginx
upstream swoole {
# Connect IP:Port, php is the name of php container
server php:5200 weight=5 max_fails=3 fail_timeout=7200s;
keepalive 16;
}
server {
...
client_max_body_size 10240m;
client_body_buffer_size 10240m;
location =/ws {
...
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_read_timeout 7200;
proxy_send_timeout 7200;
client_max_body_size 10240m;
client_body_buffer_size 10240m;
client_body_temp_path /var/www/docker/nginxtmp;
proxy_max_temp_file_size 10240m;
proxy_buffer_size 10240m;
proxy_buffers 10 2048m;
proxy_busy_buffers_size 10240m;
}
}
2.php.ini
max_execution_time = 7200
max_input_time = 7200
default_socket_timeout = 7200
memory_limit = 10240M
post_max_size = 10240M
upload_max_filesize = 10240M
3./config/laravel.php
...
'swoole' => [
'daemonize' => env('LARAVELS_DAEMONIZE', false),
'dispatch_mode' => 2,
'reactor_num' => env('LARAVELS_REACTOR_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 4),
'worker_num' => env('LARAVELS_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8),
'task_worker_num' => env('LARAVELS_TASK_WORKER_NUM', function_exists('swoole_cpu_num') ? swoole_cpu_num() * 2 : 8),
'task_ipc_mode' => 1,
'task_max_request' => env('LARAVELS_TASK_MAX_REQUEST', 51200 * 1024 * 1024),
'task_tmpdir' => @is_writable('/dev/shm/') ? '/dev/shm' : '/tmp',
'max_request' => env('LARAVELS_MAX_REQUEST', 51200 * 1024 * 1024),
'open_tcp_nodelay' => true,
'pid_file' => storage_path('laravels.pid'),
'log_file' => storage_path(sprintf('logs/swoole-%s.log', date('Y-m'))),
'log_level' => 4,
'document_root' => base_path('public'),
'buffer_output_size' => 51200 * 1024 * 1024,
'socket_buffer_size' => 51200 * 1024 * 1024,
'package_max_length' => 51200 * 1024 * 1024,
'reload_async' => true,
'max_wait_time' => 7200,
'enable_reuse_port' => true,
'enable_coroutine' => false,
'http_compression' => false,
// Slow log
// 'request_slowlog_timeout' => 2,
// 'request_slowlog_file' => storage_path(sprintf('logs/slow-%s.log', date('Y-m'))),
// 'trace_event_worker' => true,
'heartbeat_idle_time' => 600,
'heartbeat_check_interval' => 60,
...
4.另外说明
如果不配置服务器,和给上传大文件安心一点,就使用这个
https://github.com/peinhu/AetherUpload-Laravelhttps://github.com/peinhu/AetherUpload-Laravel
|