Skip to content
GenialX edited this page Nov 29, 2016 · 19 revisions

安装步骤

  1. 注册登录github账号。
  2. 创建pages项目。
  3. 新增项目 xxx.github.io (xx为你的github用户名)。
  4. 在Settings -> Developer settings -> OAuth applications中创建应用
  5. 在新创建的应用中填写一些信息 Homepage URL: http://localhost(该URL为部署爱极客程序的web地址) Authorization callback URL: http://localhost/user/github/oauth
  6. 获取Client ID 和 Client Secret(下面有用到)
  7. 搭建爱极客服务使用Github授权登陆。
  8. 配置nginx/apache
  9. 手动导入SQL(见下面)
  10. 手动改写gb_config表记录(使用client id与client secret)
  11. 改写conf/env.ini配置
  12. 访问http://localhost,开启爱极客之旅吧

服务配置

Nginx Vhost

server {
        listen   127.0.0.1:80;
        server_name githublog.lo githublog.sinaapp.com *.githublog.sinaapp.com;
        root /data1/github/githublog/;
    
        charset utf8;

        if ($uri ~ "^/static/(js|css)/") {
                rewrite ^/static/(?:js|css)/(.+\.[^.]+) /index.php/minify/show?$args&g=$1 last;                                                
        }   
        if ($uri !~ "^/(?:crossdomain\.xml|favicon\.ico|xhprof_httml/.*|static/.*|robots\.txt)$") {
                rewrite ^/(.*) /index.php/$1 last;
        }   

        location ~ ^/index.php/ {
            fastcgi_pass   127.0.0.1:9000;    
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }       

}

Apache Vhost

<VirtualHost _default_:80>
  ServerAdmin admin@ihuxu.com
  DocumentRoot /var/www/html/ga.ihuxu.com
  ServerName ga.ihuxu.com
  ErrorLog logs/ga.ihuxu.com-error_log
  TransferLog logs/ga.ihuxu.com-access_log
  <Directory /var/www/html/easdemo.echenxin.com>
    DirectoryIndex index.php index.html
  </Directory>
</VirtualHost>

Apache .htaccess

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_URI} ^/static
  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteRule ^static/(js|css)/(.+)&(.+)$ index.php/minify/show?g=$2&$3 [QSA,PT,L]

  RewriteCond %{REQUEST_FILENAME} !-d 
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

MySQL Data

CREATE TABLE IF NOT EXISTS `gb_article` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `uid` int(10) UNSIGNED NOT NULL COMMENT '作者UID',
  `category_id` int(10) UNSIGNED NOT NULL COMMENT '分类ID',
  `title` varchar(128) NOT NULL DEFAULT '' COMMENT '标题',
  `content` text NOT NULL COMMENT '内容',
  `state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0.未发布,1.已发布',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `publish_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '发布时间',
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`),
  KEY `category_id` (`category_id`,`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='文章内容';

CREATE TABLE IF NOT EXISTS `gb_blog` (
  `uid` int(10) UNSIGNED NOT NULL COMMENT '用户UID',
  `data` text NOT NULL COMMENT '内容',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`uid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='博客信息表';

CREATE TABLE IF NOT EXISTS `gb_category` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `uid` int(10) UNSIGNED NOT NULL COMMENT '所有者UID',
  `name` varchar(32) NOT NULL DEFAULT '' COMMENT '分类名称',
  `alias` varchar(32) NOT NULL DEFAULT '' COMMENT '英文别名',
  `sort` smallint(6) NOT NULL DEFAULT '0' COMMENT '排序',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq_uid_alias` (`uid`,`alias`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='分类表';

INSERT INTO `gb_category` (`id`, `uid`, `name`, `alias`, `sort`) VALUES
(1, 0, '默认分类', 'default', 0);

CREATE TABLE IF NOT EXISTS `gb_config` (
  `k` varchar(64) NOT NULL COMMENT '配置名称',
  `v` text NOT NULL COMMENT '配置值',
  PRIMARY KEY (`k`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='配置信息表';

CREATE TABLE IF NOT EXISTS `gb_counter_article` (
  `uid` int(10) UNSIGNED NOT NULL COMMENT '用户ID',
  `category_id` int(10) UNSIGNED NOT NULL COMMENT '分类ID',
  `total_number` mediumint(8) UNSIGNED NOT NULL DEFAULT '0' COMMENT '计数',
  PRIMARY KEY (`uid`,`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='文章计数器';

CREATE TABLE IF NOT EXISTS `gb_theme_main` (
  `id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '模板ID',
  `alias_id` mediumint(8) UNSIGNED NOT NULL DEFAULT '0' COMMENT '关联模板ID',
  `name` varchar(16) NOT NULL COMMENT '模板名称',
  `user_id` int(10) UNSIGNED NOT NULL COMMENT '模板作者',
  `pic` varchar(128) NOT NULL DEFAULT '' COMMENT '模板截图',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq_user_name` (`user_id`,`name`) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='模板表';


CREATE TABLE IF NOT EXISTS `gb_theme_resource` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `tpl_id` mediumint(8) UNSIGNED NOT NULL COMMENT '模板ID',
  `resource_name` varchar(32) NOT NULL COMMENT '资源名称',
  `content` text NOT NULL COMMENT '模板内容',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq_tpl_id_resource_name` (`tpl_id`,`resource_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='博客模板资源';

CREATE TABLE IF NOT EXISTS `gb_user` (
  `id` int(10) UNSIGNED NOT NULL COMMENT 'GITHUB用户UID',
  `github_access_token` varchar(255) NOT NULL DEFAULT '' COMMENT 'GITHUB的授权AccessToken',
  `metadata` text NOT NULL COMMENT '元数据',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '用户注册时间',
  `login_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '用户登录境',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户数据表';

CREATE TABLE IF NOT EXISTS `gb_publish_task` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `uid` int(10) unsigned NOT NULL COMMENT '用户UID',
  `connection_id` int(10) unsigned NOT NULL COMMENT '关联ID',
  `type` tinyint(4) NOT NULL COMMENT '发布类别',
  `metadata` text NOT NULL COMMENT '元数据',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq_uid_type_connection` (`uid`,`type`,`connection_id`) USING BTREE
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COMMENT='发布管理';

CREATE TABLE IF NOT EXISTS `gb_near` (
  `uid` int(10) unsigned NOT NULL COMMENT 'Github UID',
  `login` varchar(64) NOT NULL DEFAULT '' COMMENT '用户登录字符串',
  `location` point NOT NULL COMMENT '位置',
  `ip` int(10) unsigned NOT NULL COMMENT 'IP地址',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '数据更新时间',
  PRIMARY KEY (`uid`),
  UNIQUE KEY `unq_login` (`login`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='附近的极客';

MySQL Insert Data

INSERT INTO `gb_config` (`k`, `v`) VALUES ('github_client_id', '$your_github_clientid'), ('github_client_secret', '$your_github_client_secret');

INSERT INTO `gb_theme_main` (`id`, `alias_id`, `name`, `user_id`, `pic`, `create_time`) VALUES(1, 0, '默认模板', 0, '', '2015-11-07 21:16:48');

INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'article', '<!--{extends file=''tpl:block-main''}-->\n<!--{block name=title}--><!--{$article.title|escape}--> - <!--{$blog.data.name}--><!--{/block}-->\n<!--{block name=content}-->\n<ol class="breadcrumb">\n	<li>\n		<a href="/">首页</a>\n	</li>\n	<li>\n		<a href="/category/<!--{$category.alias}-->-1.html"><!--{$category.name|escape}--></a>\n	</li>\n	<li class="active"><!--{$article.title|escape}--></li>\n</ol>\n\n<article class="panel panel-default panel-article">\n	<div class="panel-body">\n		<h1><!--{$article.title|escape}--></h1>\n		<!--{$article.content}-->\n	</div>\n	<div class="panel-footer">\n		<time datetime="<!--{$article.create_time}-->" pubdate="<!--{$publish_date}-->" class="glyphicon glyphicon-calendar">\n			<!--{$article.create_time}-->\n		</time>\n		\n        <div class="bshare-custom share"><a title="分享到QQ空间" class="bshare-qzone"></a><a title="分享到新浪微博" class="bshare-sinaminiblog"></a><a title="分享到人人网" class="bshare-renren"></a><a title="分享到腾讯微博" class="bshare-qqmb"></a><a title="分享到网易微博" class="bshare-neteasemb"></a><a title="更多平台" class="bshare-more bshare-more-icon more-style-sharethis"></a><span class="BSHARE_COUNT bshare-share-count">0</span></div><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#style=-1&amp;uuid=&amp;pophcol=2&amp;lang=zh"></script><script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/bshareC0.js"></script>\n        <div class="clearfix"></div>\n	</div>\n</article>\n\n<!--{if $blog.data.comment_duoshuo}-->\n<div id="comment" class="comment-content panel panel-default">\n	<div class="panel-heading">评论</div>\n	<div class="panel-body">\n		<div class="ds-thread" data-thread-key="<!--{$article.id}-->" data-title="<!--{$article.title|escape}-->"></div>\n	</div>\n</div>\n<!--{/if}-->\n<!--{/block}-->', '2016-02-03 12:33:07');
INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'article-list', '<!--{extends file=''tpl:block-main''}-->\n<!--{block name=title}--><!--{$category.name|escape}--> - <!--{$blog.data.name}--><!--{/block}-->\n\n<!--{block name=content}-->\n\n<ol class="breadcrumb">\n	<li>\n		<a href="/">首页</a>\n	</li>\n	<li class="active">\n		<!--{$category.name|escape}-->\n	</li>\n</ol>\n\n<!--{include file="tpl:element-article"}-->\n\n\n<!--{$pager|page_number}-->\n<!--{/block}-->', '2016-01-02 07:13:50');
INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'block-main', '<!DOCTYPE html>\n<html lang="zh-CN">\n	<head>\n		<meta charset="utf-8">\n		<meta http-equiv="X-UA-Compatible" content="IE=edge">\n		<meta name="viewport" content="width=device-width, initial-scale=1">\n		<title><!--{block name=title}--><!--{$blog.data.name}--><!--{/block}--> - Powered By Hiblog</title>\n		<link href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css" rel="stylesheet" />\n		<link href="//chengxuan.li/HiBlog/resource/theme/default/hiblog.css" type="text/css" rel="stylesheet" />\n		<!--[if lt IE 9]>\n		<script type="text/javascript" src="http://apps.bdimg.com/libs/html5shiv/r29/html5.min.js?debug=1"></script>\n		<script type="text/javascript" src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.min.js?debug=1"></script>\n		<![endif]-->\n	</head>\n	<body class="home">\n		<div class="container-fluid">\n			<div id="sidebar" class="col-md-3 col-md-push-9" role="complementary"></div>\n			<div id="content" class="col-md-9 col-md-pull-3" role="main"><!--{block name=content}--><!--{/block}--></div>\n		</div>\n\n        <script type="text/javascript">\n        var $CONFIG = {};\n        </script>\n        \n        <!--{if !$publish}-->\n        <script type="text/javascript">\n        $CONFIG.src_sidebar = location.href.replace(/resource=[^&]+/i, "resource=sidebar");\n        </script>\n        <!--{/if}-->\n\n		<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>\n		<script type="text/javascript" src="http://apps.bdimg.com/libs/bootstrap/3.3.4/js/bootstrap.min.js"></script>\n		<script type="text/javascript" src="//chengxuan.li/HiBlog/resource/theme/default/hiblog.js"></script>\n\n		<!--{if $blog.data.comment_duoshuo}-->\n		<script type="text/javascript">\n			var duoshuoQuery = {\n				short_name : <!--{$blog.data.comment_duoshuo|json_encode}-->\n			};\n		</script>\n		<!--{/if}-->\n		\n	</body>\n</html>', '2016-01-02 03:40:20');
INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'home', '<!--{extends file=''tpl:block-main''}-->\n\n<!--{block name=content}-->\n<!--{include file="tpl:element-article"}-->\n<!--{$pager|page_number}-->\n<!--{/block}-->', '2016-01-02 03:57:30');
INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'sidebar', '<header>\n<a href="javascript:void(0)" data-toggle="collapse" data-target="#sides" aria-expanded="false" class="collapsed collapsed-sides hidden-md hidden-lg"> <span class="glyphicon glyphicon-menu-hamburger"></span> </a>\n<h2><!--{$blog.data.name|escape}--></h2>\n<p><!--{$blog.data.desc|escape}--></p>\n\n</header>\n\n<div id="sides" class="collapse in">\n<aside>\n	<h2><!--{$user.metadata.name}--></h2>\n	<div class="avatar">\n		<a target="_blank" href=""> <img src="<!--{$user.metadata.avatar_url}-->" alt="" /> </a>\n	</div>\n</aside>\n\n<aside>\n	<h2>分类目录</h2>\n	<ul>\n	    <!--{foreach from=$categorys item="item"}-->\n		<li>\n			<a href="/category/<!--{$item.alias}-->-1.html"><!--{$item.name}--></a>\n		</li>\n		<!--{/foreach}-->\n	</ul>\n</aside>\n\n<!--{if $blog.data.comment_duoshuo}-->\n<aside>\n    <h2>热门文章</h2>\n    <ul class="ds-recent-comments" data-num-items="10" data-show-avatars="1" data-show-time="1" data-show-admin="1" data-excerpt-length="70"></ul>\n</aside>\n\n<aside>\n    <h2>最新评论</h2>\n    <ul class="ds-recent-comments" data-num-items="10" data-show-avatars="1" data-show-time="1" data-show-admin="1" data-excerpt-length="70"></ul>\n</aside>\n\n<aside>\n    <h2>最近访客</h2>\n    <ul class="ds-recent-visitors"></ul>\n</aside>\n<!--{/if}-->\n\n<aside>\n	<ul>\n		<li>\n			Powered By <a target="_blank" href="https://github.com/flyhope/hiblog">Hiblog</a>\n		</li>\n	</ul>\n</aside>\n\n</div>', '2016-01-02 07:39:52');
INSERT INTO `gb_theme_resource` (`id`, `tpl_id`, `resource_name`, `content`, `update_time`) VALUES(NULL, 1, 'element-article', '<!--{foreach from=$articles item=value}-->\n<article class="panel panel-default panel-article panel-article-list" data-id="<!--{$value.id}-->">\n	<div class="panel-body">\n		<h2><a href="/article/<!--{$value.id}-->.html"><!--{$value.title|escape}--></a></h2>\n		<!--{$value.content|truncate_article}-->\n	</div>\n	<div class="panel-footer">\n	    <a href="/category/<!--{$value.category.alias}-->-1.html"><!--{$value.category.name}--></a>\n		<a class="time hidden-sm" href="/article/<!--{$value.id}-->.html"><time datetime="<!--{$article.create_time}-->" pubdate="<!--{$value.update_time|truncate:10}-->" class="glyphicon glyphicon-calendar"></time> <!--{$value.create_time}--></a>\n		<!--{if $blog.data.comment_duoshuo}-->\n		<a class="comment" href="/article/<!--{$value.id}-->.html#comment"><span class="glyphicon glyphicon-comment"></span> <span class="ds-thread-count" data-thread-key="<!--{$value.id}-->" data-count-type="comments"></span></a>\n		<!--{/if}-->\n		<div class="clearfix"></div>\n	</div>\n</article>\n<!--{/foreach}-->', '2016-02-03 12:33:47');

Clone this wiki locally