Tag Archives: install

ruby gems 更改源

因为众所周知的原因,gem update,install等命令经常会遇到超时timeout,半天无响应,卡住等问题,建议换成淘宝的镜像源:

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

https://ruby.taobao.org
# 请确保只有 ruby.taobao.org
$ gem install rails

 

 

参考资料:http://ruby.taobao.org/

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,也可能没有,没经过测试,仅作参考。

解决freebsd升级到最新ports遇到的问题

系统环境

uname -a
FreeBSD AN 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Wed Jul 31 16:20:23 CST 2013   amd64

更新系统的ports tree

先su获取root权限:

portsnap fetch
portsnap extract

出错

安装vim:

cd /usr/ports/editors/vim
make install clean

出错:

Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

"Makefile", line 137: Malformed conditional (${PYTHON_REL} < 300)
"Makefile", line 142: if-less endif
Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

"/usr/ports/Mk/bsd.sites.mk", line 953: Malformed conditional (!empty(_PERL_CPAN_ID) && ${_PERL_CPAN_FLAG:tl} == "cpan")
Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

Unknown modifier 't'

"/usr/ports/Mk/bsd.port.mk", line 2877: Unclosed conditional/for loop
"/usr/ports/Mk/bsd.port.mk", line 2877: Unexpected end of file in for loop.

"/usr/ports/Mk/bsd.port.mk", line 6590: Unclosed conditional/for loop
"/usr/ports/Mk/bsd.port.mk", line 6590: Unexpected end of file in for loop.

1 open conditional:
         at line 1177 (evaluated to true)
make: fatal errors encountered -- cannot continue

谷歌查了一下,原因是7.0这个release不是一个正在维护的版本了,更新后的ports tree和当前的版本不兼容。

解决办法

  • 升级当前系统到最新版本
  • 重新恢复port tree到当前对应版本

stackoverflow的一篇帖子给了我灵感,到freebsd的找到了ports tree的官方备份网站找到了压缩包,恢复之: 用root用户下载install.sh和ports.tgz到/root文件夹,执行脚本解压

sh ./install.sh

FreeBSD源代码安装tsung

我之前的一篇文章《FreeBSD安装tsung》介绍过在FreeBSD下用ports安装erlang和tsung,但是FreeBSD里面的软件太古老,很难安装成功,特别是安装java遇到很大的挫折,之后又尝试源代码安装erlang和tsung,发现一般情况下可以去掉java选项,可以使安装过程变得简单很多。

1.OS版本

64位的Freebsd,uname -a命令:

FreeBSD AN 7.0-RELEASE FreeBSD 7.0-RELEASE #2: Fri Apr 11 10:34:32 CST 2014   amd64

2.安装gmake

需要root权限:

cd /usr/ports/devel/gmake/
make install clean

2.安装erlang

版本:otp-src-R16B03.tar.gz,“gmake install”需要root权限:

tar zxvf otp_src_R16B03.tar.gz
cd otp_src_R16B03 && ./configure --without-javac && gmake && gmake install

3.安装tsung

版本:tsung-1.5.0.tar.gz,“gmake install”需要root权限:

tar zxvf tsung-1.5.0.tar.gz
cd tsung-1.5.0 && ./configure && gmake && gmake install

4.参考文献

FreeBSD安装tsung

1.OS版本

FreeBSD AN 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Wed Dec 12 23:19:45 CST 2012

2.tsung的一些依赖关系

  • Erlang/OTP R12B-5 and up (http://www.erlang.org/download.html). Erlang is now part of fedora and debian/ubuntu repositories.
  • pgsql module made by Christian Sunesson (for the PostgreSQL plugin): sources available at http://jungerl.sourceforge.net/ . The module is included in the source and binary distribution of Tsung. It is released under the EPL License.
  • mysql module made by Magnus Ahltorp & Fredrik Thulin (for the mysql plugin): sources available at http://www.stacken.kth.se/projekt/yxa/ . The modified module is included in the source and binary distribution of Tsung. It is released under the three-clause BSD License.
  • eldap module (for the LDAP plugin): sources available at http://jungerl.sourceforge.net/ . The module is included in the source and binary distribution of Tsung. It is released under the GPL License.
  • mochiweb libs (for xpath parsing, optionally used for dynamic variables in the HTTP plugin): sources available at http://code.google.com/p/mochiweb/ . The module is included in the source and binary distribution of Tsung. It is released under the MIT License.
  • gnuplot and perl5 (optional; for graphical output with tsungstats.pl script). The Template Toolkit is used for HTML reports (see http://template-toolkit.org/)
  • python and mathplotlib (optional; for graphical output with tsung-plotter).

for distributed tests, you need an ssh access to remote machines without password (use a RSA/DSA key without pass-phrase or ssh-agent) (rsh is also supported)

  • bash

一般情况下,我们只需要安装erlang,Freebsd默认没有java解释器,所以需要安装java解析器还有erlang.

3.FreeBSD安装java

有开源的java解决方案,也有oracle的官方版本,详情请看: http://www.freebsd.org/java/ http://www.freebsd.org/java/install.html

这里使用开源的openjdk:

cd /usr/ports/java/openjdk6 
make install clean

4.安装tsung

获得tsung,不需要最新的,用官方推荐的R12B版本就行:

wget http://www.erlang.org/download/otp_src_R12B-5.tar.gz
tar zxvf otp_src_R12B-5.tar.gz
cd cd otp_src_R12B
./configure && make && make install

5.可能会出现的问题

5.1 无法找到java解释器

*********************************************************************
------------------  APPLICATIONS DISABLED  **********************
*******************************************************************

jinterface     : No Java compiler found
odbc           : ODBC library - link check failed

*********************************************************************

需要按照步骤3安装java解释器

5.2 安装openssl出错

bss_dgram.c: In function 'dgram_sctp_handle_auth_free_key_event':
bss_dgram.c:962: error: 'SCTP_AUTH_FREE_KEY' undeclared (first use in this function)
bss_dgram.c:962: error: (Each undeclared identifier is reported only once
bss_dgram.c:962: error: for each function it appears in.)
bss_dgram.c: In function 'dgram_sctp_read':
bss_dgram.c:1053: error: 'SCTP_SENDER_DRY_EVENT' undeclared (first use in this function)
bss_dgram.c:1085: error: 'struct sctp_event_subscribe' has no member named 'sctp_sender_dry_event'
bss_dgram.c: In function 'BIO_dgram_sctp_wait_for_dry':
bss_dgram.c:1544: error: 'struct sctp_event_subscribe' has no member named 'sctp_sender_dry_event'
bss_dgram.c:1595: error: 'SCTP_SENDER_DRY_EVENT' undeclared (first use in this function)
bss_dgram.c:1612: error: 'struct sctp_event_subscribe' has no member named 'sctp_sender_dry_event'
--- Error code 1

Stop in /usr/ports/security/openssl/work/openssl-1.0.1c/crypto/bio.

make -DBATCH install clean
--- Error code 1

Stop in /usr/ports/security/openssl/work/openssl-1.0.1c/crypto.
--- Error code 1

Stop in /usr/ports/security/openssl/work/openssl-1.0.1c.
--- Error code 1

Stop in /usr/ports/security/openssl.
--- Error code 1

Stop in /usr/ports/security/openssl.

去掉STCP的选项:

cd /usr/ports/security/openssl
make config

去掉 []SCTP SCTP protocol support,然后:

make clean
make instal clean

5.3 很多已经安装,需要更新

出错信息类似:

tall'' to upgrade it properly.
      If you really wish to overwrite the old port of devel/libcheck
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
--- Error code 1

安装的时候加入选项FORCEPKGREGISTER=”yes”

make FORCE_PKG_REGISTER="yes" install clean

安装过程可能还会缺少很多软件,很可能需要手工安装。顺便发一下牢骚,freebsd的ports系统真没有gentoo好用。

6.参考文献

这里还教你如何使用tsung

FreeBSD 源代码安装samba服务器

关于samba的知识,这里不介绍,请参考维基百科:

http://en.wikipedia.org/wiki/Samba_(software)

http://zh.wikipedia.org/wiki/Samba

 

这里以安装比较稳定的版本3.0.37为例。

1.下载源代码

http://ftp.samba.org/pub/samba/

 

2.解压:tar xvfz samba-3.0.37.tar.gz

3.cd samba-3.0.37/source

4../configure

5.make

6.make install(需要root 权限)

7.配置samba

(1)编辑/etc/inetd.conf文件(需要root权限)

  netbios-ssn stream tcp nowait root /usr/local/samba/sbin/smbd smbd
   netbios-ns dgram udp wait root /usr/local/samba/sbin/nmbd nmbd
   swat stream tcp nowait.400 root /usr/local/samba/sbin/swat swat
注意路径
(2)拷贝配置文件:

cp samba-3.0.37/examples/smb.conf.default /usr/local/samba/lib/smb.conf
(3)编辑配置文件:
security = share
 hosts allow = 192.168.0.1   《—-允许访问的ip地址列表
guest account = root
定义访问的规则
[policy]
   path = /home/……
   public = yes
#   only guest = yes
   writable = yes
   printable = no