歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

在Fedora18安裝下一代靜態網站生成框架Awestruct

Awestruct是非常棒的靜態網站生成框架,他基於Jekyll,使用Ruby語言開發。Awestruct可以根據模板生 成非常漂亮的網站,例如可以用BootStrap或者BluePrint,這兩個大名鼎鼎的東東不用多說了吧,地球人都知 道。廢話不多說,進入主題。安裝Ruby環境

首先安裝一些依賴庫,否則安裝Awestruct會報如下的錯誤 :

Building native extensions.  This could take a while... 
......... 
ERROR:  Error installing 下一代靜態網站生成工具:         
        ERROR: Failed to build gem native extension. .         
        /usr/bin/ruby extconf.rb 
checking for stdio.h... *** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers.  Check the mkmf.log file for more 
details.  You may need configuration options. 
. 
Provided configuration options:         
        --with-opt-dir         
        --without-opt-dir         
        --with-opt-include         
        --without-opt-include=${opt-dir}/include         
        --with-opt-lib         
        --without-opt-lib=${opt-dir}/lib         
        --with-make-prog         
        --without-make-prog         
        --srcdir=.         
        --curdir         
        --ruby=/usr/bin/ruby 
/usr/share/ruby/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. 

(RuntimeError) 
You have to install development tools first.         
        from /usr/share/ruby/mkmf.rb:506:in `try_cpp'         
        from /usr/share/ruby/mkmf.rb:931:in `block in have_header'         
        from /usr/share/ruby/mkmf.rb:790:in `block in checking_for'         
        from /usr/share/ruby/mkmf.rb:284:in `block (2 levels) in postpone'         
        from /usr/share/ruby/mkmf.rb:254:in `open'         
        from /usr/share/ruby/mkmf.rb:284:in `block in postpone'         
        from /usr/share/ruby/mkmf.rb:254:in `open'         
        from /usr/share/ruby/mkmf.rb:280:in `postpone'         
        from /usr/share/ruby/mkmf.rb:789:in `checking_for'         
        from /usr/share/ruby/mkmf.rb:930:in `have_header'         
        from extconf.rb:2:in `<main>'

開始安裝依賴庫,用 root 用戶或者 su 執行如下 命令:

yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel

我是 Fedora的粉絲,對不住用其它發行版的童鞋了,請自行根據我列出的安裝包找到對應的系統安裝方法。

安裝Ruby和RubyGems,用 root 用戶或者 su 執行如下命令:

yum install ruby ruby-devel ruby-irb rubygems

Fedora18 Yum源的Ruby非常新,都是目前(2012-12-14)的最新版本,看看安裝的 Ruby版本:

正在安裝    : libyaml-0.1.4-3.fc18.x86_64                                     

      1/10
正在安裝    : ruby-libs-1.9.3.327-22.fc18.x86_64                                    2/10
正在安裝    : ruby-irb-1.9.3.327-22.fc18.noarch                                     3/10
正在安裝    : rubygem-json-1.6.5-2.fc18.x86_64                                      4/10
正在安裝    : rubygem-io-console-0.3-22.fc18.x86_64                                 5/10
正在安裝    : rubygem-bigdecimal-1.1.0-22.fc18.x86_64                               6/10
正在安裝    : rubygem-rdoc-3.12-5.fc18.noarch                                       7/10
正在安裝    : rubygems-1.8.24-3.fc18.noarch                                         8/10
正在安裝    : ruby-1.9.3.327-22.fc18.x86_64                                         9/10
正在安裝    : ruby-devel-1.9.3.327-22.fc18.x86_64

安裝Awestruct

Awestruct使用 RubyGems管理安裝,用 root 用戶或者 su 執行如下命令:

gem install 下一代靜態網站生成工具 - -no-ri --no-rdoc

結果報如下錯誤:

Fetching: nokogiri-1.5.5.gem (100%) 
ERROR:  Error installing 下一代靜態網站生成工具:         
        invalid gem format for /usr/local/share/gems/cache/nokogiri-1.5.5.gem

這個問題讓 我郁悶了N久時間,Google了大半天,還特意搞了FANQIANG,結果死活裝不上nokogiri。最後通過Yum來解決, 我只能說RubyGems安裝很無恥!還是YUM好!,命令如下:

yum install -y rubygem-nokogiri

再次安裝Awestruct:

yum install -y rubygem-nokogiri

盼望已久的時刻來臨,如果哪位童鞋 看到如下的輸出,Congratulations!

Successfully installed 下一代靜態網站生成工具-0.4.7 17 gems installed

不過別高興太早,先適用下是否OK!用BootStrap模板生產一個新的靜態網站,命令如 下:

下一代靜態網站生成工具 -i -f bootstrap //或者用awestruct --init --framework bootstrap

傻眼了,還是報錯:

[root@localhost kuuyee]# 下一代靜態網站生成工具 -i -f 

bootstrap 
/usr/local/share/gems/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not 

find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available 

runtimes. (ExecJS::RuntimeUnavailable)         
        from /usr/local/share/gems/gems/execjs-1.4.0/lib/execjs.rb:5:in `<module:ExecJS>'  

       
        from /usr/local/share/gems/gems/execjs-1.4.0/lib/execjs.rb:4:in `<top (required)>' 

        
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `<top 

(required)>'              
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'     
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `<top 

(required)>'              
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'     
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-

0.4.7/lib/awestruct/handlers/coffeescript_handler.rb:8:in `<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/handler_chains.rb:14:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/pipeline.rb:2:in `<top 

(required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/engine.rb:6:in `<top 

(required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/cli/generate.rb:1:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/cli/invoker.rb:4:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/bin/awestruct:6:in `<top (required)

>'         
        from /usr/local/bin/awestruct:23:in `load'         
        from /usr/local/bin/awestruct:23:in `<main>'

顧名思義,提示沒有JavaScript Runtime。繼續Google,最後一位高人指點說裝個JavaScript引擎就OK,我選擇NodeJS。只可惜NodeJSF沒有 YUM源,只能源碼編譯安裝,無所謂,繼續:

wget -c 'http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz'
tar zxvf node-v0.8.16.tar.gz  
cd node-v0.8.16
./configure  
make && make install

又是一陣漫長的等待,搞不明白一個JS框架怎麼要編譯這麼久,無 語!最後編譯完成測試一下:

[root@localhost node-v0.8.16]# node -v v0.8.16

OK,繼續 Awestruct測試:

[root@localhost kuuyee]# 下一代靜態網站生成工具 -i -f bootstrap 
/usr/local/share/gems/gems/git-1.2.5/lib/git/lib.rb:700:in `command': git version   

2>&1:sh: git: 未找到命令 (Git::GitExecuteError)         
        from /usr/local/share/gems/gems/git-1.2.5/lib/git/lib.rb:649:in 

`current_command_version'         
        from /usr/local/share/gems/gems/git-1.2.5/lib/git/lib.rb:659:in 

`meets_required_version?'         
        from /usr/local/share/gems/gems/git-1.2.5/lib/git.rb:30:in `<top (required)>'      

   
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/deploy/base_deploy.rb:2:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/deploy/s3_deploy.rb:1:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/cli/deploy.rb:1:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/cli/invoker.rb:7:in 

`<top (required)>'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/share/rubygems/rubygems/custom_require.rb:36:in `require'         
        from /usr/local/share/gems/gems/awestruct-0.4.7/bin/awestruct:6:in `<top (required)

>'         
        from /usr/local/bin/awestruct:23:in `load'         
        from /usr/local/bin/awestruct:23:in `<main>'

竟然還TMD報錯,不過這回不用急 ,只是提示沒裝Git,好辦!那就裝呗:

yum install git

再繼續Awestruct:


[root@localhost kuuyee.org]# 下一代靜態網站生成工具 -i -f bootstrap
Create directory: /root/git_project/kuuyee.org/_config
Create directory: /root/git_project/kuuyee.org/_layouts
Create directory: /root/git_project/kuuyee.org/_ext
Create file: /root/git_project/kuuyee.org/_ext/pipeline.rb
Create directory: /root/git_project/kuuyee.org/stylesheets
directory _site/stylesheets/ 
directory images/ 
directory javascripts/ 
   create stylesheets/styles.scss 
   create images/glyphicons-halflings.png 
   create images/glyphicons-halflings-white.png 
   create javascripts/bootstrap-alert.js 
   create javascripts/bootstrap-button.js 
   create javascripts/bootstrap-carousel.js 
   create javascripts/bootstrap-collapse.js 
   create javascripts/bootstrap-dropdown.js 
   create javascripts/bootstrap-modal.js 
   create javascripts/bootstrap-popover.js 
   create javascripts/bootstrap-scrollspy.js 
   create javascripts/bootstrap-tab.js 
   create javascripts/bootstrap-tooltip.js 
   create javascripts/bootstrap-transition.js 
   create javascripts/bootstrap-typeahead.js 
   create _site/stylesheets/styles.css 
    
Now you're 下一代靜態網站生成工具!
    
To generate your site continuous during development, simply run:
    
下一代靜態網站生成工具 -d
    
and visit your site at
    
  http://localhost:4242/
    
Create file: /root/git_project/kuuyee.org/_layouts/base.html.haml
Create file: /root/git_project/kuuyee.org/index.html.haml

Congratulations! 這回真的恭喜 你了!趕緊部署一下:

[root@localhost kuuyee]#  下一代靜態網站生成工具 -d
Unable to locate profile: development
Using profile: NONE
Generating site: http://localhost:4242
Generating: /1003/awestruct-sample/_site/images/glyphicons-halflings-white.png
Generating: /1003/awestruct-sample/_site/images/glyphicons-halflings.png
Generating: /1003/awestruct-sample/_site/index.html
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-alert.js
/usr/local/share/gems/gems/awestruct-0.4.7/lib/awestruct/handlers/interpolation_handler.rb:35: 

Use RbConfig instead of obsolete and deprecated Config.
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-button.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-carousel.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-collapse.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-dropdown.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-modal.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-popover.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-scrollspy.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-tab.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-tooltip.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-transition.js
Generating: /1003/awestruct-sample/_site/javascripts/bootstrap-typeahead.js
Analyzing:  /1003/awestruct-sample/_site/stylesheets/styles.css
[Listen warning]:
  Missing dependency 'rb-inotify' (version '~> 0.8.8')!
  Please run the following to satisfy the dependency:   
    gem install --version '~> 0.8.8' rb-inotify   
.  
  For a better performance, it's recommended that you satisfy the missing dependency.
  Listen will be polling changes. Learn more at https://github.com/guard/listen#polling-

fallback.
.
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4242, CTRL+C to stop

打開 http://localhost:4242/ 看看吧!

BootStrap網站模板

細心的童鞋一定會注意到部署輸出有警告,我是屬於不想看到任何警告的 人,所以還得繼續,清楚警告:

gem install --version '~> 0.8.8' rb-inotify

再次部署訪問就不會有警告了!

大功告成!祝願各位童鞋安裝成功!

Copyright © Linux教程網 All Rights Reserved