前提
- 伺服器 laravel6 升級到 laravel9
- 只有介面, 改動不會太大
- Octane 啟用
- Jenkins 方式部署
- 寶塔管理
1.路由升級
protected $namespace = 'App\Http\Controllers';
protected $namespace = '';
Route::get('/link_test/index', 'LinkTestController@index');
Route::get('/link_test/root_list', 'LinkTestController@root_list');
Route::prefix('link_test')->group(function () {
Route::controller(\App\Http\Controllers\Api\LinkTestController::class)->group(function () {
Route::get('/index', 'index');
Route::get('/root_list', 'root_list');
});
});
Route::post('/add/test', [\App\Http\Controllers\Api\AddTestController::class, 'category']);
composer
fideloper/proxy
tymon/jwt-auth
fzaninotto/faker 為 fakerphp/faker
laravel/octane
laravel/sanctum
Octane伺服器
升級寶塔皮膚
- 安裝 php8.1
- 安裝擴充套件
- 安裝 supervisor
supervisor配置
/www/server/php/81/bin/php -d variables_order=EGPCS /www/wwwroot/learn/blog/artisan octane:start --host="0.0.0.0" --port=8003 --workers=8 --max-requests=100000 --task-workers=4
Nginx 修改重寫規則
location /e33 {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
try_files $uri $uri/ @octane;
}
location @octane {
set $suffix "";
if ($uri = /index.php) {
set $suffix ?$query_string;
}
proxy_set_header Host $host;
proxy_set_header SERVER_PORT $server_port;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HTTPS "on";
proxy_pass http://127.0.0.1:8003$suffix;
}
Jenkins修改
/www/wwwroot/default/kill_port.sh 8003
/www/server/panel/pyenv/bin/supervisorctl -c /etc/supervisor/supervisord.conf restart learn:learn_00
$request->post('type', 1)
$request->input('type', 1)
結語
- 測試由原來的 40ms 變為現在的 20ms 上下
- 網址
本作品採用《CC 協議》,轉載必須註明作者和本文連結