LaravelS是一个胶水项目,用于快速集成SwooleLaravel,然后赋予它们更好的性能、更多可能性.

  环境 : ubuntu16 + nginx + php7.1 + LaravelS搭建高性能php服务器。

依赖 说明
PHP >= 5.5.9
Swoole >= 1.7.19 推荐最新的稳定版 从2.0.12开始不再支持PHP5
Laravel/Lumen >= 5.1
Gzip[可选的] zlib,用于压缩HTTP响应,检查本机libz是否可用 ldconfig -p|grep libz
Inotify[可选的] inotify,用于修改代码后自动Reload Worker进程,检查本机inotify是否可用 php --ri inotify
1:环境监测
 

php -v   (检查php)
cc -v (检查 gcc)
openssl version (检查openssl)
php --ri swoole (检查 swoole)

2:安装swoole

sudo wget https://github.com/swoole/swoole-src/archive/v4.0.4.zip
sudo unzip v4.0.4.zip *** 如果没有unzip,先安装 sudo apt install unzip 再 sudo unzip v4.0.4.zip cd swoole-src-4.0.4 (进入解压包)
sudo phpize ***如果没有phpize 先安装 sudo apt-get install php7.1-dev 再 sudo phpize sudo ./configure
sudo make
sudo make install
安装成功后,在php中加入so
位置 /etc/php/7/1/cli/php.ini
添加配置 extension=swoole.so 检查版本 php --ri swoole

3:安装laravels

  注:若还没有 Laravel 环境请参考  https://www.cnblogs.com/cj8988/p/9454142.html

1、在你的Laravel/Lumen项目的根目录下执行
composer require "hhxsv5/laravel-s:~3.0" -vvv 2、注册Service Provider
  Laravel: 修改文件config/app.php,Laravel 5.5+支持包自动发现,你应该跳过这步
  'providers' => [
Hhxsv5\LaravelS\Illuminate\LaravelSServiceProvider::class,
],

3、发布配置文件,每次升级LaravelS后,建议重新发布一次配置文件
php artisan laravels publish 4、.修改配置config/laravels.php:监听的IP、端口等。

5、运行
  php artisan laravels {start|stop|restart|reload|publish}
命令 说明
start 启动LaravelS,展示已启动的进程列表 ps -ef|grep laravels
stop 停止LaravelS
restart 重启LaravelS
reload 平滑重启所有worker进程,这些worker进程内包含你的业务代码和框架(Laravel/Lumen)代码,不会重启master/manger进程
publish 发布配置文件到你的项目中config/laravels.php

4、配置nginx

在   nginx.conf  配置中添加

gzip on;
gzip_min_length 1024;
gzip_comp_level 2;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml;
gzip_vary on;
gzip_disable "msie6"; upstream laravels {
# By IP:Port
server 127.0.0.1:5200 weight=5 max_fails=3 fail_timeout=30s;
}
在service配置中添加

server {
listen 80;
server_name laravels.com;
root /xxxpath/laravel-s-test/public;
access_log /yyypath/log/nginx/$server_name.access.log main;
autoindex off;
index index.html index.htm;
# Nginx处理静态资源(建议开启gzip),LaravelS处理动态资源。
location / {
try_files $uri @laravels;
}
location @laravels {
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Scheme $scheme;
proxy_set_header Server-Protocol $server_protocol;
proxy_set_header Server-Name $server_name;
proxy_set_header Server-Addr $server_addr;
proxy_set_header Server-Port $server_port;
proxy_pass http://laravels;
}
}

参考文档   https://laravel-china.org/articles/8050/laravels-speed-up-laravellumen-through-swoole

       https://github.com/hhxsv5/laravel-s

最新文章

  1. java后台调用url无协议
  2. 如何替换掉.net toolStrip控件溢出按钮背景图
  3. TextView中gravity属性值测定
  4. find命令使用, -exec xargs
  5. HTML5之本地文件系统API - File System API
  6. swiper,animate使用方法
  7. 蚂蚁金服mPaaS 3.0发布 助力客户智能化构建超级App生态
  8. ArcGIS发布地图服务时报错Error: ArcGIS Server site is currently being configured by another administrative operation. Please try again later.
  9. ORACLE相关函数使用总结
  10. spring相关jar包
  11. pxe+Kickstart自动装机补充知识点
  12. 1.C和C++的区别
  13. 简单的一个MySQL类的实现:
  14. PAT 1017 A除以B(20)(代码)
  15. Alpha阶段敏捷冲刺(四)
  16. yum-阿里源配置
  17. js变量提升
  18. mysql 1449 : The user specified as a definer ('root'@'%') does not exist
  19. Android应用截图方法
  20. 基础004_V7-DSP Slice

热门文章

  1. C# Label背景透明
  2. Java中的阻塞队列-ArrayBlockingQueue(一)
  3. Java之美[从菜鸟到高手演变]之智力题【史上最全】 (转)
  4. 一本通 1260:【例9.4】拦截导弹(Noip1999)
  5. 关于 header()前面 为什么不能有任何输出的问题
  6. C++ Knowledge series 5
  7. html5 chrome 摄像头 &&bootstrap
  8. php的yii框架开发总结7
  9. TP5.1:数据库的增删改查操作(基于面向对象操作)
  10. 如何在VMware ubuntu linux虚拟机中安装VMware tools