缘起
今儿在折腾新东西的时候想到,能不能结合wp强大的sql查询机制+lumen开发架构搞一套接口出来,想到了就开干。首先搭建wp、创建主题,然后将lumen下载到主题文件夹下面,这些都很简单,但困难的地方在于怎么样访问能按照lumen的规则,也就相当在这个主题中存在了一个新的程序,也就是lumen,而要直接使用域名/lumen,这样访问是不行的,需要配置Nginx规则。
这就是折腾了三个多小时的原因了。
解决
location / {
index index.html index.php;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
location ^~ /api-json/ {
alias /www/wwwroot/ka.clearnull.com/wp-content/themes/encrypted-information/sliver-api/public/;
index index.php;
try_files $uri $uri/ @lumen;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/tmp/php-cgi-72.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /www/wwwroot/ka.clearnull.com/wp-content/themes/encrypted-information/sliver-api/public/index.php;
}
}
location @lumen {
rewrite /api-json/(.*)$ /api-json/index.php?/$1 last;
}
注意:将/www/wwwroot/ka.clearnull.com/wp-content/themes/encrypted-information/sliver-api/public/为你自己网站的路径
注意:将/tmp/php-cgi-72.sock; 换为你自己的监听地址
QQ交流群: 824144151
技术援助
需要技术援助?点击这里,帮你解决你的所有问题!PS:可能你离大神之间,只差一个我们!!!!