用gitblog建一个blog

来源:互联网 发布:js escape 替代 编辑:程序博客网 时间:2024/06/05 10:35

最近建了个bolg: www.xiaoxiaoguo.cn
欢迎访问 O(∩_∩)O

一.空间选用

1.国内:选阿里云或者腾讯云就可以了.
2.国外:选国外的空间的优势是不用备案这些,域名解析好后可以立即访问.但速度比不上国内的空间.
推荐两个:
1).亚马逊aws
我现在用的就是aws,首次用免费一年,如果仅仅是跑个blog足够了.
2.)digitalocean
目前翻墙用了这家的空间,节点有纽约,新加坡,伦敦等,速度比较稳定,建议用新加坡的点.首次充值5刀,送10刀,等于送了两个月.
链接:https://www.digitalocean.com/?refcode=d1885bd8c9c8

二.搭建gitblog

1.获取gitblog

sudo mkdir -p /data/gitblog访问 https://github.com/jockchou/gitblog/releases下载相应的版本,并解压到/data/gitblog#修改下权限sudo chown -R apache:apache /data/gitblog/app/cachesudo chown -R apache:apache /data/gitblog/app/logs

2.在nginx下使用

#先安装下nginx等yum install php-fpm nginx -yyum install php-mbstring -y#修改下nginx配置vi /etc/nginx/nginx.conf#添加如下配置user nginx;worker_processes auto;error_log /var/log/nginx/error.log;pid /run/nginx.pid;events {    worker_connections 1024;}http {    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                      '$status $body_bytes_sent "$http_referer" '                      '"$http_user_agent" "$http_x_forwarded_for"';    access_log  /var/log/nginx/access.log  main;    sendfile            on;    tcp_nopush          on;    tcp_nodelay         on;    keepalive_timeout   65;    types_hash_max_size 2048;    include             /etc/nginx/mime.types;    default_type        application/octet-stream;    server {        listen       80 default_server;        listen       [::]:80 default_server;        server_name  _;        root         /data/gitblog;        index       index.php;        location / {            if (!-e $request_filename) {                rewrite ^(.*)$ /index.php?$1 last ;                break;            }        }         location ~ .*\.(php|php5)?$        {            fastcgi_connect_timeout 300;            fastcgi_send_timeout 300;            fastcgi_read_timeout 300;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;            include        fastcgi_params;        }        error_page 404 /404.html;            location = /40x.html {        }        error_page 500 502 503 504 /50x.html;            location = /50x.html {        }    }}

3.在apache下使用

如果你的服务器是Apache的,则需要如下设置:

1).开启rewrite模块。默认应该是开启的,如果没有,需要在http的配置文件中增加如下内容:

LoadModule rewrite_module /usr/lib/path/to/modules/mod_rewrite.so

2).将该虚拟机主机的配置全新修改下:
修改 “AllowOverride None” 中的 “None” 为 “All”;

Options FollowSymLinksAllowOverride AllRequire all denied

3).在网站的根目录添加.htaccess,内容如下

DirectoryIndex index.phpRewriteEngine onRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteCond $1 !^(index\.php|robots\.txt)RewriteRule ^(.*)$ index.php?/$1 [L]

4.启动nginx 或apahce

nginxservice nginx start  service php-fpm start apacheservice httpd start 

5.gitblog使用

gitblos使用简单,把博文放到/data/gitblog/blog下,注意文件格式是markdown的,后缀名用md,内容的头部格式要符合要求,例如:

author: xiaoguohead: http://pingodata.qiniudn.com/jockchou-avatar.jpgdate: 2015-12-07 17:30:50title: keepalived lvs 要注意的点tags: keepalivedcategory: keepalived lvsstatus: publishsummary: keepalived 要注意的点

更详细的内容可以看:
http://gitblogdoc.sinaapp.com/

三.后续维护

1.blog状态监控
可以用nagios等,如果想简单,可以用奇云测,免费版的可以选3个节点,如果有故障,会短信通知
http://jk.cloud.360.cn/

2.有时更新了一个blog,但页面没有更新,需要清理下缓存

sudo rm -fr /data/gitblog/app/cache
0 0