Tag Archives: ubuntu

ubuntu 12.04安装jekyll

ubuntu版本

$ cat /etc/issue
Ubuntu 12.04 LTS \n \l

$ uname -a
Linux ubuntu 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 i686 i686 i386 GNU/Linux

安装ruby和jekyll

没有gem就安装。

调整为taobao源

$ gem sources --remove https://rubygems.org/
$ gem sources --remove http://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
\*** CURRENT SOURCES ***

https://ruby.taobao.org
# 请确保只有 ruby.taobao.org

安装rvm和ruby:

$ sudo apt-get install curl
$ sudo gem install rvm
$ \curl -sSL https://get.rvm.io | bash
$ source /home/user/.rvm/scripts/rvm
$ rvm install ruby-2.1.2
$ rvm use ruby-2.1.2

安装js runtime:

$ sudo apt-get install nodejs
$ gem install execjs

安装jekyll:

$ gem install jekyll

备注: 由于apt-get安装的软件可能版本相对较老,因此推荐用rvm安装ruby。

可能遇到的一些问题

ERROR: Failed to build gem native extension

错误情况:

$ sudo gem install jekyll
Fetching: liquid-2.6.1.gem (100%)
Fetching: kramdown-1.4.1.gem (100%)
Fetching: mercenary-0.3.4.gem (100%)
Fetching: safe_yaml-1.0.3.gem (100%)
Fetching: colorator-0.1.gem (100%)
Fetching: yajl-ruby-1.1.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing jekyll:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from extconf.rb:1:in `<main>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/yajl-ruby-1.1.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/yajl-ruby-1.1.0/ext/yajl/gem_make.out

原因: ruby版本过老,apt-get install ruby的版本一般是1.8,请使用rvm安装2.1版本的ruby;哪些最新可用版本请用rvm list known查看。

Could not find a JavaScript runtime

错误情况:

$ jekyll new myblog
/home/user/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/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 /home/user/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/lib/execjs.rb:5:in `<module:ExecJS>'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/execjs-2.2.1/lib/execjs.rb:4:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/coffee-script-2.3.0/lib/coffee_script.rb:1:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/coffee-script-2.3.0/lib/coffee-script.rb:1:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-coffeescript-1.0.0/lib/jekyll-coffeescript.rb:2:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-2.3.0/lib/jekyll/deprecator.rb:46:in `block in gracefully_require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-2.3.0/lib/jekyll/deprecator.rb:44:in `each'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-2.3.0/lib/jekyll/deprecator.rb:44:in `gracefully_require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-2.3.0/lib/jekyll.rb:141:in `<top (required)>'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /home/user/.rvm/gems/ruby-2.1.2/gems/jekyll-2.3.0/bin/jekyll:6:in `<top (required)>'
        from /home/user/.rvm/gems/ruby-2.1.2/bin/jekyll:23:in `load'
        from /home/user/.rvm/gems/ruby-2.1.2/bin/jekyll:23:in `<main>'
        from /home/user/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
        from /home/user/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

错误原因: 未安装相关js库,请安装nodejs和execjs,请参照以上步骤。

注意事项

安装步骤是针对ubuntu 12.04,其他版本的ubuntu可能有最新的ruby,也可能没有,没经过测试,仅作参考。

总结升级ubuntu和debian遇到的一些错误及解决办法

如没有特别说明,以下操作均需要root权限。

mysql: symbol lookup error

cd /usr/local/lib
mkdir temp
mv /usr/local/lib/libreadline* temp
ldconfig
apt-get update

The following signatures couldn’t be verified because the public key is not available

apt-get update的时候,有时候会出现公钥错误,比如:

W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2EA8F35793D8809A

或者:

W: There is no public key available for the following key IDs:
8B48AD6246925553

解决办法:安装keyring,往ubuntu server添加公钥信息.

sudo apt-get install debian-keyring debian-archive-keyring && sudo apt-key update
sudo apt-key adv --recv-key --keyserver keyserver.ubuntu.com 8B48AD6246925553

注意第二条命令中的key ID替换成你的key ID.

升级ubuntu从11.10到12.04,网络出现异常

错误描述:无法打开网络配置工具,开机启动出现如下:

Waiting up to 60 more seconds for network configuration...

解决办法:确保你的文件”/etc/network/interfaces”只有如下两行:

auto lo
iface lo inet loopback

有多余的请删除,然后重新启动。

debian安装goagent

debian 版本:Debian GNU/Linux 7 按照官方网站的ubuntu的安装步骤安装所需软件,因为debian里面的包比较古老,因此推荐从源代码安装或者从github安装最新的软件版本。我在运行proxy.py的时候就出现如下问题:

Traceback (most recent call last):
  File "proxy.py", line 1341, in <module>
    http_util = HTTPUtil(max_window=common.GOOGLE_WINDOW, ssl_validate=common.GAE_VALIDATE or common.PAAS_VALIDATE, ssl_obfuscate=common.GAE_OBFUSCATE, proxy=common.proxy)
  File "proxy.py", line 810, in __init__
    self.ssl_context = OpenSSL.SSL.Context(OpenSSL.SSL.TLSv1_METHOD)
AttributeError: 'NoneType' object has no attribute 'SSL'

原因是debian的pyopenssl包比较老,推荐用python的包管理器安装:

sudo apt-get install python-pip
sudo pip install pyOpenSSL