存档

文章标签 ‘ruby’

ruby + mechanize +logger

2012年10月6日 评论已被关闭

centos 6 下较折腾

yum install ruby rubygems libxml2 libxml2-devel ruby-devel libxslt libxslt-devel

gem install logger

gem install mechanize

debian 6 里最省事

apt-get  install ruby1.9.1-full ruby-log4r ruby-mechanize

 

 

分类: 技术点滴 标签: , , ,

用gem翻墙在线安装rubygem.org的软件

2011年10月6日 评论已被关闭

伟大的gfw折腾了我大半个下午,后来才发现自己在gem的时候被gfw给reset了。错误信息如下

ERROR:  While executing gem … (Gem::RemoteFetcher::FetchError)
too many connection resets (http://production.s3.rubygems.org/latest_specs.4.8.gz)

找国内的源镜像没找到。搜到一个哥们说用nginx做反向代理加速gem的。救星啊。。。

http://huacnlee.com/blog/using-nginx-proxy-to-mirror-rubygem-org

如法炮制之,我用的apache做的反向代理,配置如下

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://rubygems.org/
ProxyPassReverse / http://rubygems.org/
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName production.cf.rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://production.cf.rubygems.org/
ProxyPassReverse / http://production.cf.rubygems.org/
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName production.s3.rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://production.s3.rubygems.org/
ProxyPassReverse / http://production.s3.rubygems.org/
</VirtualHost>

然后hosts里再把这3个域名做到vps的ip去即可。

1.1.2.84 rubygems.org
1.1.2.84 production.cf.rubygems.org
1.1.2.84 production.s3.rubygems.org

 

shallwe说有时还需要https(我是没用上),https的反向代理设置如下

yum install mod_ssl -y

vi /etc/httpd/conf.d/ssl.conf

<VirtualHost *:443>

SSLEngine on
SSLProxyEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
DocumentRoot /var/www/html
ServerName production.s3.rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / https://production.s3.rubygems.org/
ProxyPassReverse / https://production.s3.rubygems.org/
</VirtualHost>

<VirtualHost *:443>

SSLEngine on
SSLProxyEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
DocumentRoot /var/www/html
ServerName production.cf.rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / https://production.cf.rubygems.org/
ProxyPassReverse / https://production.cf.rubygems.org/
</VirtualHost>

<VirtualHost *:443>

SSLEngine on
SSLProxyEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
DocumentRoot /var/www/html
ServerName rubygems.org
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / https://rubygems.org/
ProxyPassReverse / https://rubygems.org/
</VirtualHost>

ruby的gem常用方法,及安装openssl支持,解决 “require LoadError: no such file to load — openssl”错误

2011年9月4日 评论已被关闭

一开始是用gem的方法装,结果装了好几个openssl相关的却错误依然,” require LoadError: no such file to load — openssl”。

放狗搜了下,发现需要在ruby的源代码目录的ext目录下安装一次方可

cd ruby-1.9.2-p290/ext/openssl/ ;ruby  extconf.rb ; make ; make install

为了折腾个东西,不得不接触ruby。总结一下gem的用法。

最好自己装一次最新的gem,ruby 1.9.2自带那个好像用起来有问题。下载 http://production.cf.rubygems.org/rubygems/rubygems-1.8.10.tgz ,然后ruby setup.rb 即可安装最新的gem

gem push xxx.gem,本地安装xxx.gem

要找gem可以到http://rubygems.org/ 搜索

gem env可以查看当前gem的变量

gem sources -r  http://rubygems.org 删除源

gem sources -a http://gems.rubyforge.org 添加源

 

升级gem系统

分类: 技术点滴 标签: , ,