Ruby 环境搭建时 openssl.so LoadError 问题

在CentOS 下布署ROR环境时, gem update 指令报如下错误

/opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so: undefined symbol: EC_GROUP_new_curve_GF2m - /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/x86_64-linux/openssl.so (LoadError)
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/openssl.rb:17:in `<top (required)>'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /opt/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

应该是 openssl 版本问题所致,解决方案如下:
Installing OpenSSL anywhere besides /usr puts the libraries in the expected lib instead of lib64. (Don’t ask me why… dunno.) This may be the more maintainable solution as it lets you avoid hacking up the Makefile. This is also the solution RVM uses when running rvm pkg install openssl. Thus, to install both OpenSSL and Ruby (in /opt), you may run commands something like these (I run as sudo bash):
Install OpenSSL:
cd /opt/local
wget http://www.openssl.org/source/openssl-1.0.1f.tar.gz
tar -xzf openssl-1.0.1f.tar.gz
cd openssl-1.0.1f
./config --prefix=/opt/local shared no-asm zlib > openssl_config.log
make > openssl_make.log
make install > openssl_install.log

(The shared switch is required for Ruby to install without error, the no-asm switch helps get rid of a Make warning but does not appear to be required, and zlib and other switches are optional.)
Optional, update openssl certs:
cd /opt/local/ssl
wget http://curl.haxx.se/ca/cacert.pem
mv cacert.pem cert.pem
cd /opt

Back to Ruby: 连接指定的OpenSSL 安装
ruby-install ruby 1.9.3-p545 -- --with-openssl-dir=/opt/local
或者RVM环境下:
rvm install 1.9.3 --with-openssl-dir=/opt/local

问题解决, gem update 成功!

mysql 的权限赋予,备忘一下

grant [all | all privileges  |select | update … ]  #权限  all privileges = all
on dbname.table_name [*] #库名表名
to somebody@111.111.111.%  #用户名@IP端,可用%代替
identified by ‘123’ #登录密码

Tomcat 内存设置

set JAVA_OPTS=-Xms128m -Xmx1532m -XX:PermSize=128M -XX:MaxPermSize=1024m
加到 catalina.bat 或 sh里

ubuntu 12.10 里居然把五笔包移除了?

装上了 ubuntu 12.10 看看,结果 sudo apt-get install ibus-table-wubi 居然报错,该软件包被引用,但已经在目录树中被移除。只好退回到 12.04LTS版了。
看来还是12.04LTS 版稳定一些。木有五笔输入法,对于一个习惯了五笔的家伙,用拼音打字是相当痛苦的事情。

winserver 下注册 mysql 服务

布署了个免安装式的mysql 注册服务让它自启动

bin\mysqld --install mysql --defaults-file=&quot;%cd%\my.ini&quot;

当然my.ini 的位置视当前的情况定咯
然后 netstart mysql 启动就好了

最近迁移布署 常用命令

fdisk & disk – l  & df 查看系统硬盘信息和使用情况
lspci 查看主板信息等
cat /proc/cpuinfo CPU信息
cat /proc/meminfo 内存信息
du -h –max-depth=1 递归查看当前文件夹内的文件和直属子文件夹的大小
scp -r  root@192.168.12.111:/opt/*     /opt/   scp 远程拷贝

修改 Ubuntu 的系统时区

root@www:~# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan           18) Israel                35) Palestine
 2) Armenia               19) Japan                 36) Philippines
 3) Azerbaijan            20) Jordan                37) Qatar
 4) Bahrain               21) Kazakhstan            38) Russia
 5) Bangladesh            22) Korea (North)         39) Saudi Arabia
 6) Bhutan                23) Korea (South)         40) Singapore
 7) Brunei                24) Kuwait                41) Sri Lanka
 8) Cambodia              25) Kyrgyzstan            42) Syria
 9) China              ...
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
...
#? 1
The following information has been given:
        China
        east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ='Asia/Shanghai' will be used.
Local time is now:      Fri Nov 30 15:20:21 CST 2012.
Universal Time is now:  Fri Nov 30 07:20:21 UTC 2012.
Is the above information OK?
1) Yes
2) No
#? 1
You can make this change permanent for yourself by appending the line
        TZ='Asia/Shanghai'; export TZ
to the file '.profile' in your home directory; then log out and log in again.
Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
root@www:~# cat >>~/.profile <<EOF
> TZ='Asia/Shanghai'; export TZ
> EOF
root@www:~# rm -rf /etc/localtime

Linux 服务器 后台 Too many open files 错误解决方案

最近用 Apache HttpClient的包做爬虫,发现Tomcat 的 日志文件总是报 Too many open files 。 原因是 Ubutu 下默认一个 app 的访问文件限制是 1024个。而 HttpClient 在execute 之后,为提升效率,默认是 CLOSE-WAIT 回收的。遂算做对一个文件的使用。

ps -C java #取得tomcat 进程的PID
lsof -p 30780 > a.txt  #查看PID=30780 的进程占用的文件,输出到 a.txt

发现到达上限了,使用命令增加允许占用文件上限即可

ulimit -n 10240

方法2:/etc/security/limits.conf里设置:

hard nofile 65535
soft nofile 65535

tomcat 7中EL表达式报"is not a valid Java identifier"…

最近前tomcat 6 下布署的项目挪到 tomcat 7 下 , 404页面挂掉了。网上翻了翻:
在tomcat 7中默认会检查EL表达式中是否会有java关键字。比如SomeException#getClass()#getName()中有class关键 字,${exception.class.name}这样就是会报错,解决方法是${exception[‘class’].name},再如 Session#isNew() ,要${pageContext.session[‘new’]}这样表达。
参考https://issues.apache.org/bugzilla/show_bug.cgi?id=50147
或者有另种比较暴力的解决方法,就是修改配置文件,不让检查java关键字。
在tomcat 7中“org.apache.el.parser.SKIP_IDENTIFIER_CHECK”默认是false的。
解决方法:
$CATALINA_BASE/conf/catalina.properties 增加
org.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false
org.apache.el.parser.SKIP_IDENTIFIER_CHECK=true
 
$CATALINA_BASE/conf/Catalina/localhost/webapp.xml 增加
<Context path=”” docBase=”/vmind/vmind”  useHttpOnly=”false”  debug=”0″ reloadable=”false”>
或修改server.xml的context选项,增加useHttpOnly=”false”  即可。
参考:http://blog.csdn.net/eagleking012/article/details/6822847

linux 下 挂载 windows 共享的资源

 mount -t cifs -o username=administrator,password=administrator //192.168.0.229/resource /media/resource