通过SCL安装Ruby 2.3 🔗
jekyll需要ruby 2.1+,所以使用SCL安装ruby 2.3:
通过SCL安装Ruby 2.3 🔗
jekyll需要ruby 2.1+,所以使用SCL安装ruby 2.3:
1# 1. Install a package with repository for your system:
2# On CentOS, install package centos-release-scl available in CentOS repository:
3yum install centos-release-scl
4
5# 2. Install the collection:
6yum install rh-ruby23
7
8# 3. Show available connections
9scl --list
jekyll安装 🔗
1# 1. 启用 ruby2.3环境
2scl enable rh-ruby23 bash
3
4# 2. 安装jekyll及插件
5gem install jekyll jekyll-paginate
jekyll主题 🔗
我们使用的主题来自 huxpro.github.io,并做了定制 可以从github下载,效果图如下:
nginx服务设置 🔗
1#安装nginx
2yum install -y nginx
3
4#创建nginx的root目录
5mkdir -p /var/www/html
6
7#设置nginx根目录对于git服务可写
8chown -R git.git /var/www/html
9# /etc/nginx/nginx.conf
10#
11# For more information on configuration, see:
12# * Official English Documentation: http://nginx.org/en/docs/
13# * Official Russian Documentation: http://nginx.org/ru/docs/
14
15user nginx;
16worker_processes auto;
17error_log /var/log/nginx/error.log;
18pid /run/nginx.pid;
19
20# Load dynamic modules. See /usr/share/nginx/README.dynamic.
21include /usr/share/nginx/modules/*.conf;
22
23events {
24 worker_connections 1024;
25}
26
27http {
28 log_format main '[$time_local] $remote_addr $server_name "$request" '
29 '$status $body_bytes_sent "$http_referer" '
30 '"$http_user_agent" "$http_x_forwarded_for" '
31 '$upstream_addr $request_time $upstream_response_time';
32 #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
33 # '$status $body_bytes_sent "$http_referer" '
34 # '"$http_user_agent" "$http_x_forwarded_for"';
35
36 access_log /var/log/nginx/access.log main;
37
38 sendfile on;
39 tcp_nopush on;
40 tcp_nodelay on;
41 keepalive_timeout 65;
42 types_hash_max_size 2048;
43
44 include /etc/nginx/mime.types;
45 default_type application/octet-stream;
46
47 # Load modular configuration files from the /etc/nginx/conf.d directory.
48 # See http://nginx.org/en/docs/ngx_core_module.html#include
49 # for more information.
50 include /etc/nginx/conf.d/*.conf;
51
52 server {
53 listen 80 default_server;
54 listen [::]:80 default_server;
55 server_name _;
56 root /usr/share/nginx/html;
57
58 # Load configuration files for the default server block.
59 include /etc/nginx/default.d/*.conf;
60
61 location / {
62 root /var/www/html;
63 }
64
65 error_page 404 /404.html;
66 location = /40x.html {
67 }
68
69 error_page 500 502 503 504 /50x.html;
70 location = /50x.html {
71 }
72 }
73}
git服务设置 🔗
1# 添加git用户, 并将shell设置为git-shell
2useradd git --shell /usr/bin/git-shell
3
4# 创建git仓库
5mkdir -p /home/git/blog.git
6git init --bare /home/git/blog.git
7chown -R git.git /home/git/blog.git
8
9#!/bin/bash
10# hooks/post-receive
11
12scl enable rh-ruby23 - << \EOF
13git clone /home/git/blog.git /tmp/tmp-blog-build-repo
14jekyll build -s /tmp/tmp-blog-build-repo -d /var/www/html
15EOF
16
17rm -Rf /tmp/tmp-blog-build-repo
18exit