用gitblog建一个blog

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

一.空间选用

1.国内:选阿里云或者腾讯云就可以了.
2.国外:选国外的空间的优势是不用备案这些,域名解析好后可以立即访问.但速度比不上国内的空间.
推荐几个:
1).亚马逊aws
我现在用的就是aws,首次用免费一年,如果仅仅是跑个blog足够了.
2.)digitalocean
目前翻墙用了这家的空间,节点有纽约,新加坡,伦敦等,速度比较稳定,建议用新加坡的点.首次充值5刀,送10刀,等于送了两个月.
3.)Google Cloud Platform
google云现在也免费一年,地区asia-east1-c的延迟很低,国内25ms左右的延迟

二.搭建gitblog

1.获取gitblog

sudo mkdir -p /data/gitblog
访问 https://github.com/jockchou/gitblog/releases
下载相应的版本,并解压到/data/gitblog

#修改下权限
sudo chown -R apache:apache /data/gitblog/app/cache
sudo chown -R apache:apache /data/gitblog/app/logs

2.在nginx下使用

#先安装下nginx等
yum install php-fpm nginx -y
yum 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 FollowSymLinks
AllowOverride All
Require all denied

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

DirectoryIndex index.php

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)

RewriteRule ^(.*)$ index.php?/$1 [L]

4.启动nginx 或apahce

nginx
service nginx start  
service php-fpm start 

apache
service httpd start 

5.gitblog使用

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

author: xiaoguo
head: http://pingodata.qiniudn.com/jockchou-avatar.jpg
date: 2015-12-07 17:30:50
title: keepalived lvs 要注意的点
tags: keepalived
category: keepalived lvs
status: publish
summary: keepalived 要注意的点

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

三.后续维护

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

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

sudo rm -fr /data/gitblog/app/cache
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值