安装Jekyll本地环境

Posted by phantomVK on May 6, 2019

Jekyll 依赖 Ruby 语言,需要先安装

$ sudo apt install ruby

类似 pipPythonRubyGemsRuby 的包管理器,其终端命令为 gem。安装 Ruby 之后用 gem 直接安装 Jekyll 可能会报以下错误:

$ sudo gem install jekyll 
Fetching: public_suffix-3.1.1.gem (100%)
Successfully installed public_suffix-3.1.1
Fetching: addressable-2.6.0.gem (100%)
Successfully installed addressable-2.6.0
Fetching: colorator-1.1.0.gem (100%)
Successfully installed colorator-1.1.0
Fetching: http_parser.rb-0.6.0.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
/usr/bin/ruby2.5 -r ./siteconf20190706-17669-1vutbo1.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.5.0/gems/http_parser.rb-0.6.0 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/http_parser.rb-0.6.0/gem_make.out

因此需安装 Ruby 的开发插件

$ sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev

继续安装 Jekyll

$ sudo gem install jekyll

其次 Jekyll 还依赖 jekyll-paginate

$ sudo gem install jekyll-paginate

所有配置完成后,终端移动到目标文件夹下启动服务即可

$ jekyll serve

参考链接: