原文鏈接:http://chinacheng.iteye.com/blog/1480145
情況大體是這樣的,接手了別人在配的一臺服務器,Red Hat Enterprise Linux Server release 5.5。
至於他的ruby gem之類的安裝包是怎麼安裝的我一概不知,問他他就說按照步驟來的,但是各種問題層出不窮。首先是環境變量的問題,這個好解決,一步搞定了。
之後是gem包的安裝問題,只要運行 gem install * 命令,都會出現下面這個錯誤:
- ERROR: Loading command: install (LoadError)
- no such file to load — zlib
- ERROR: While executing gem … (NameError)
- uninitialized constant Gem::Commands::InstallCommand
這個錯誤,在google上搜索,答案真的是一片一片的,但是所有的答案無非都是下面這幾句話,千篇一律整齊劃一,好不無奈
install the zlib dev libraries
- sudo apt-get install zlib1g-dev
Then go to the source directory from where you compiled the Ruby and there you will find source for zlib.
e.g. /usr/local/src/ruby-1.8.7/ext/zlib
In case, if you used RVM, then it will be here
- cd /home/user/.rvm/src/ruby-1.8.7-p352/ext/zlib
- And do the following commands
- ruby extconf.rb
- make
- make install
上面這個答案明顯是針對ubuntu的,我這臺服務器既不能聯外網,又不是ubuntu,所以完全不能效顰
我去搜索zlib包,幾乎完全被ubuntu的deb文件刷屏,最後還好找到了(見附件)
configure & make & make install
很順利,很成功
但是仍然有錯誤,我把gem重新安裝還是沒用的,於是懷疑是ruby在編譯安裝的時候沒有編譯這個zlib。
乾脆把ruby重新編譯安裝,問題搞定,看來就是上面我猜測的這個原因。
之後我覺得,上面引文中的
/home/user/.rvm/src/ruby-1.8.7-p352/ext/zlib 目錄下 去擴展一下也應該是可以的
- ruby extconf.rb
- make
- make install
只是我這邊ruby重新編譯之後問題成功了,也沒有必要去復現這個問題了
====================================================================
http://netfork.iteye.com/blog/432928
passenger編譯安裝nginx的時候出錯:
checking for openssl/ssl.h... no
一、安裝openssl擴展
編譯安裝
- tar -zxvf openssl-0.9.8k.tar.gz
- cd openssl-0.9.8k
- ./configure
- make && make install
二、然後到源碼
文件夾的/ext/openssl文件夾
- cd ruby-1.8.7-p330/ext/openssl
- ruby extconf.rb --with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib
- make && make install
如果遇到
- /usr/bin/ld: /usr/local/ssl/lib/libssl.a(s2_meth.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
- /usr/local/ssl/lib/libssl.a: could not read symbols: Bad value
- collect2: ld returned 1 exit status
服務器是64位的,
- ./config shared -fPIC
按照上面命令重新編譯openssl
再重新安裝ruby的ext擴展
- make distclean
- ruby extconf.rb --with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib
- make && make install
================================
passenger-install-nginx-moudle 出現如下錯誤
- StaticContentHandler.c:69: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
註釋掉gem包中的
- Delete these line from ${GEM_HOME}/passenger-2.2.15/ext/nginx/StaticContentHandler.c
- if (r->zero_in_uri) {
- return NGX_DECLINED;
- }
參見 https://github.com/hmsk/nginx-passenger-centos
===============================
nginx啓動出現錯誤
- nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
進入/lib64目錄中手動鏈接下(服務器是64位的)
- ln -s libpcre.so.0.0.1 libpcre.so.1