GithubHelp home page GithubHelp logo

gaoyongfu / yaf-server-admin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fingerqin/yaf-server-admin

0.0 0.0 0.0 14.27 MB

使用 Yaf 开发的一套 API 服务端与管理后台的组合。已经把常见功能(登录、注册、短信、文章、友情链接、APP升级)实现了。用本套系统能快速开发业务代码。

License: GNU Lesser General Public License v3.0

PHP 97.07% Hack 2.92% Batchfile 0.01%

yaf-server-admin's Introduction

Yaf-Server 使用文档

Yaf-Server 是一个基于 Yaf 框架实现的通用型服务端项目开发框架。将一些常见业务场景已经实现。从而达到快速开发不同业务项目的目的。所谓通用型业务场景包含:登录、注册、短信发送、APP 消息推送、日志存储、文件上传、API 接口、管理后台等。该文档旨在说明这些通用业务的设计思路,以及底层封装的通用方法的使用。让团队成员快速融入到项目的开发及维护当中。

Yaf-Server 只提供 API 接口、内嵌页(APP调用)、命令行(Cli)访问。为什么不提供 PC版、手机触屏版是因为它们的会话需要 SESSION 机制,以及我们采用了前端团队采用 Nodejs 来渲染的机制。所以,我们只安安心心做接口提供服务就好。管理后台在单独的项目 Yaf-Admin 内实现。

项目使用文档请阅读 docs 目录下的文档。

Yaf-Server 部署文档

1 环境说明

Nginx   -> Nginx 1.x (1系列最新版)
PHP     -> PHP 7.1.x 以上(含)
MySQL   -> MySQL 5.6.x
Redis   -> Redis 3.x (3系列最新版即可)

2 PHP 扩展安装

2.1 Yaf 扩展安装

因为我们的 Yaf-Server 基建项目用是基于 Yaf 框架开发,所以必须安装 Yaf 扩展。

$ wget http://pecl.php.net/get/yaf-3.0.7.tgz
$ tar zxvf yaf-3.0.7.tgz
$ cd yaf-3.0.7
$ phpize
$ make && make install

然后,在 php.ini 配置文件末尾增加如下代码:

extension = yaf.so
yaf.use_spl_autoload = 1

注:这里我要说明一下:PHP 5.x 系列安装 yaf-2.x 系列最新版本的扩展,PHP 7.x 系列安装 yaf-3.x 系统最新版本的扩展。

2.2 Redis 扩展安装

Redis 我们用来做系统缓存、Session 分布式存储、消息队列等功用。所以必须安装 Redis 扩展。我们安装最新稳定版本的 Redis 扩展即可。

$ wget http://pecl.php.net/get/redis-4.1.0.tgz
$ tar zxvf redis-4.1.0.tgz
$ cd redis-4.1.0
$ phpize
$ make && make install

然后,在 php.ini 配置文件末尾增加如下代码:

extension = redis.so

2.3 event 扩展安装[可选]

考虑到后续系统可能会使用诸如一些事件相关的函数或第三方扩展。如 workerman 。所以,我们推荐安装此扩展。

$ wget http://pecl.php.net/get/event-2.3.0.tgz
$ tar zxvf event-2.3.0.tgz
$ cd event-2.3.0
$ phpize
$ make && make install

然后,在 php.ini 配置文件末尾增加如下代码:

extension = event.so

注:在安装此扩展之前,我们要先安装 libevent 扩展。

2.4 其他扩展

在开发中,我们会使用到 PHP 内置的一些方法。而这些方法需要 PHP 内置扩展支持。有些内置扩展默认是关闭的。有些扩展安装的时候被关闭了。所以,我们在安装的时候要确保以下扩展是开启状态。

posix
pcntl
openssl
mcrypt
json
ftp
gd
ctype

3 Nginx 配置

假设我们的相关信息如下:

  • 域名:local.server.yaf.com
  • 项目入口目录:/data/wwwroot/codespace/myself/Yaf-Server/public
server {
  listen 80;
  server_name local.server.yaf.com;
  access_log /data/wwwlogs/local.server.yaf.com_nginx.log combined;
  index index.html index.htm index.php;
  include /usr/local/nginx/conf/rewrite/yaf.conf;
  root /data/wwwroot/codespace/myself/Yaf-Server/public;
  
  #error_page 404 = /404.html;
  #error_page 502 = /502.html;
  
  location ~ \.php {
    fastcgi_pass remote_php_ip:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
      set $real_script_name $1;
      #set $path_info $2;
    }
    fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
    fastcgi_param SCRIPT_NAME $real_script_name;
    #fastcgi_param PATH_INFO $path_info;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
}

/usr/local/nginx/conf/rewrite/yaf.conf 包含了如下信息:

location / {
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=$1 last;
        break;
    }
}

4 hosts 配置

因为我们是在本地开发环境配置。所以,我们需要配置系统 hosts 文件。

127.0.0.1 local.server.yaf.com

5 日志目录可写权限

项目根目录下的 logs 目录是存放项目所有日志的位置。请把它设置为可写。

$ chmod -R 0777 ./logs

###6 Composer update

由于 Yaf-Server 使用 Composer 安装了 Mongodb 等第三方包。所以,我们首次部署环境时,需要把这些包下载回来。

请确认自己环境已经安装了 Composer

进入项目根目录执行如下命令进行安装第三方包:

composer update

7 账号密码

账号:13812345678
密码:123456

管理后台登录的时候会请求 Yaf-Server 项目的发短信的接口。配置文件当中环境设置为开发时,验证码默认为:123456。但是,请务必保证管理后台能调用到 Yaf-Server 的短信接口。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.