关于laravel:第二篇Laravel10测试性能及ngnix配置Laravel10-Vue30前后端分离框架通用后台源码

6次阅读

共计 880 个字符,预计需要花费 3 分钟才能阅读完成。

章节目录
【第一篇 Laravel10 装置】Laravel10 + Vue3.0 前后端拆散框架通用后盾源码

vscode 关上 laravel10-vue3-admin

routes/web.php

新增如下代码

Route::get('/hello', function () {echo "hello";});

运行成果,36s

剖析性能,简略 hello 都要 36s。连贯数据库,加上代码逻辑。预计要 100s+ 呢。因为之前采纳的是,php artisan serve,这边换 ngnix 环境尝试一下,看一下访问速度是否有变动

配置 ngnix
关上 file:///usr/local/etc/nginx/servers/laravel10-vue3.notestore.cn 文件没有则新建哦

内容如下:

server {

    listen 80;
    server_name laravel10-vue3.notestore.cn;
    index index.html index.php;
    root /Users/beichen/Documents/laravel10-vue3-admin/backend/public;
    
 
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        fastcgi_pass     127.0.0.1:9000;
        fastcgi_index    index.php;
        include          fastcgi_params;
        fastcgi_param    SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }  

    location / {try_files $uri $uri/ /index.php$is_args$query_string;}

}

重启 ngnix 服务
brew services restart nginx

进入
/etc

hosts 文件,新增如下
127.0.0.1 laravel10-vue3.notestore.cn

成果如下,38s。如同变动不大,拜访仍旧很慢,晚点连贯数据库,测试一下性能

正文完
 0