OAuth2.0服务开发

使用开源组件oauth2-server-php
github上下载
建立域名auth.qzjiao.com
Nginx设置

server {
    listen       80;
    server_name  auth.qzjiao.com;
index index.html index.htm index.php;
root  /appsite/auth/www;
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
    expires max;
    log_not_found off;
}
if ($host ~* ^www\.(.*))
{
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
   }
if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
{
           rewrite ^(.*)$ / permanent;
    }
if ($request_uri ~* index/?$)
{
        rewrite ^/(.*)/index/?$ /$1 permanent;
    }
if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }
    if ($request_uri ~* ^/system)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }
if (!-e $request_filename)
    {
        rewrite ^/(.*)$ /index.php?/$1 last;
        break;
    }
location ~ .*\.(php|php5)?$
    {
         #fastcgi_pass  unix:/tmp/php-cgi.sock;
          fastcgi_pass  127.0.0.1:9000;
          fastcgi_index index.php;
          include fcgi.conf;
    }
include        /appsite/nginx/conf/drop.conf;
access_log  /appsite/nginx/logs/auth.log  main;
error_page   500 502 503 504  /50x.html;
}

进入third_party目录

git clone https://github.com/bshaffer/oauth2-server-php
mv -f oauth2-server-php Oauth2
cd Oauth2 
composer install

如果composer未安装可以执行以下:

PATH=/../bin/php:$PATH
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

如果composer install报错,去掉composer.json中mongodb配置

参考
https://segmentfault.com/a/1190000004105563

标签: 无

发表评论: