微服务很火,实验室要求大部分语言接入微服务,比如:NET、JAVA、前端、PHP。微服务本来就是JAVA的,作为一个phper,只有想办法接入微服务。
网上可以参考的东西不多,但还是找到了可利用的东西。
先实现php注册到Spring Cloud的注册中心:http://eureka.springcloud.cn/
结果如图:
把php应用部署到openresty + PHP(FPM)
注册工具SpringCloudOpenresty
https://github.com/tangaiyun/SpringCloudOpenrestyPHP
前提:安装openresty和php 7.0和FPM
使用的系统:ubuntu14.04
安装openresty
源码包下载:
http://openresty.org/cn/download.html
找个目录放源码:cd /rootwget https://openresty.org/download/openresty-1.13.6.2.tar.gz相关依赖包的安装apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential解压源码,安装openrestytar -xzvf openresty-1.13.6.2.tar.gzcd openresty-1.13.6.2./configuremake && make install
验证安装成功
开启openresty
/usr/local/openresty/nginx/sbin/nginx
curl 12