Laravel5中设置Server运行模式

  1. 修改app\Console\Kernel.php

     protected $commands = [
         // Commands\Inspire::class,
         \Qufenqi\Stone\Console\Commands\StoneServer::class, // 添加这一行
     ];
    
  2. 定义请求处理类, 我定义在app\Servers\Handler.php

    注意 这个其实就是 stone.php 配置里的 server.handler

     <?php namespace App\Servers;
    
     use Qufenqi\Stone\Contracts\RequestHandler;
     use Response;
    
     class Handler implements RequestHandler
     {
         public function process()
         {
             return Response::make('hello, stone server!');
         }
    
         public function onWorkerStart()
         {
    
         }
     }
    
  3. 运行Stone-Server

     sudo php ./artisan stone:server
    
  4. 修改nginx配置

     location /server/ {
         fastcgi_split_path_info ^(.+\.php)(/.+)$;
         fastcgi_index index.php;
         fastcgi_pass unix:/var/run/stone-server-fpm.sock; # Stone
         include fastcgi_params;
     }
    
     sudo nginx -s reload
    
  5. 完成

results matching ""

    No results matching ""