Jekyll使用说明
- 安装Nginx,并设置反向代理,提供80端口访问
root@VM-0-8-freebsd:~ # pkg install nginx
启动nginx
root@VM-0-8-freebsd:~ # service nginx start
Cannot 'start' nginx. Set nginx_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
root@VM-0-8-freebsd:~ # service nginx onestart
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
root@VM-0-8-freebsd:~ # ps axu |grep nginx
root 55772 0.0 0.4 11436 7240 - Ss 22:53 0:00.00 nginx: master process /usr/local/sbin/nginx
www 55773 0.0 0.4 11436 7700 - S 22:53 0:00.00 nginx: worker process (nginx)
root 55796 0.0 0.0 412 308 1 R+ 22:53 0:00.00 grep nginx
设置开机启动 echo "nginx_enable='YES'" >> /etc/rc.conf
root@VM-0-8-freebsd:~ # echo "nginx_enable='YES'" >> /etc/rc.conf
root@VM-0-8-freebsd:~ # service nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
查看配置文件,并测试 nginx -t
root@VM-0-8-freebsd:~ # nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
-
安装 jekyll 和 bundler gems
gem install jekyll bundler
- 创建 Jekyll 站点
jekyll new blog
进入到nginx的默认站点目录,创建myblog站点 。FreeBSD位于/usr/local/www
root@VM-0-8-freebsd:/usr/local/www # jekyll new myblog
Running bundle install in /usr/local/www/myblog...
Bundler: Fetching gem metadata from https://rubygems.org/..........
Bundler: Resolving dependencies...
... 省略 ...
New jekyll site installed in /usr/local/www/myblog.
- 进入站点目录
cd /usr/local/www/myblog/
root@VM-0-8-freebsd:/usr/local/www/myblog # ls
.gitignore 404.html Gemfile Gemfile.lock _config.yml _posts about.markdown index.markdown
- 编译,启动服务
bundle 实现虚拟环境,类似于 pyenv
执行bundle config set --local path 'vendor/bundle'
执行bundle install
bundle exec jekyll serve
root@VM-0-8-freebsd:/usr/local/www/myblog # bundle exec jekyll serve
Configuration file: /usr/local/www/myblog/_config.yml
Source: /usr/local/www/myblog
Destination: /usr/local/www/myblog/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.292 seconds.
Please add the following to your Gemfile to avoid polling for changes:
require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /(?i-mx:bsd|dragonfly)/
gem 'rb-kqueue', '>= 0.2'
end
Auto-regeneration: enabled for '/usr/local/www/myblog'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
Pass the --livereload option to serve to automatically refresh the page with each change you make to the source files: bundle exec jekyll serve --livereload
日常使用nohup bundle exec jekyll serve --livereload &
运行
root@VM-0-8-freebsd:/usr/local/www/myblog # nohup bundle exec jekyll serve --livereload &
[1] 54362
root@VM-0-8-freebsd:/usr/local/www/myblog # Configuration file: /usr/local/www/myblog/_config.yml
Source: /usr/local/www/myblog
Destination: /usr/local/www/myblog/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.292 seconds.
Please add the following to your Gemfile to avoid polling for changes:
require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /(?i-mx:bsd|dragonfly)/
gem 'rb-kqueue', '>= 0.2'
end
Auto-regeneration: enabled for '/usr/local/www/myblog'
Server address: http://127.0.0.1:4000/
LiveReload address: http://127.0.0.1:35729
Server running... press ctrl-c to stop.
- Browse to http://localhost:4000
- 配置反向代理
root@VM-0-8-freebsd:/usr/local/etc/nginx # mkdir conf.d/
root@VM-0-8-freebsd:/usr/local/etc/nginx # echo "include /usr/local/etc/nginx/conf.d/*.conf;" >> nginx.conf
在conf.d目录创建myblog.conf文件,如下:
server {
listen 80;
#server_name www.123.com;
location / {
proxy_pass http://127.0.0.1:4000;
index index.html index.htm index.jsp;
}
}
网友评论