Redhat安裝gem包報錯“no such file to load — zlib”以及ruby的openssl擴展等錯誤的修正

原文鏈接:http://chinacheng.iteye.com/blog/1480145

情況大體是這樣的,接手了別人在配的一臺服務器,Red Hat Enterprise Linux Server release 5.5。 

至於他的ruby gem之類的安裝包是怎麼安裝的我一概不知,問他他就說按照步驟來的,但是各種問題層出不窮。 
首先是環境變量的問題,這個好解決,一步搞定了。 
之後是gem包的安裝問題,只要運行 gem install * 命令,都會出現下面這個錯誤: 

Java代碼  收藏代碼
  1. ERROR:  Loading command: install (LoadError)  
  2. no such file to load — zlib  
  3. ERROR:  While executing gem … (NameError)  
  4. uninitialized constant Gem::Commands::InstallCommand  


這個錯誤,在google上搜索,答案真的是一片一片的,但是所有的答案無非都是下面這幾句話,千篇一律整齊劃一,好不無奈 
引用

install the zlib dev libraries 
Java代碼  收藏代碼
  1. 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 
Java代碼  收藏代碼
  1. cd /home/user/.rvm/src/ruby-1.8.7-p352/ext/zlib  
  2. And do the following commands  
  3. ruby extconf.rb  
  4. make  
  5. 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 目錄下 去擴展一下也應該是可以的 
Java代碼  收藏代碼
  1. ruby extconf.rb  
  2. make  
  3. make install  

只是我這邊ruby重新編譯之後問題成功了,也沒有必要去復現這個問題了 

==================================================================== 

http://netfork.iteye.com/blog/432928 

passenger編譯安裝nginx的時候出錯: 
checking for openssl/ssl.h... no 

一、安裝openssl擴展 

編譯安裝 
Java代碼  收藏代碼
  1. tar -zxvf openssl-0.9.8k.tar.gz  
  2. cd openssl-0.9.8k  
  3. ./configure  
  4. make && make install  

二、然後到源碼 
文件夾的/ext/openssl文件夾 
Java代碼  收藏代碼
  1. cd ruby-1.8.7-p330/ext/openssl  
  2.   
  3. ruby extconf.rb --with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib  
  4.   
  5. make && make install  


如果遇到 
Java代碼  收藏代碼
  1. /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  
  2. /usr/local/ssl/lib/libssl.a: could not read symbols: Bad value  
  3. collect2: ld returned 1 exit status  


服務器是64位的, 
Java代碼  收藏代碼
  1. ./config shared -fPIC  

按照上面命令重新編譯openssl 
再重新安裝ruby的ext擴展 
Java代碼  收藏代碼
  1. make distclean  
  2. ruby extconf.rb --with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib  
  3. make && make install  



================================ 
passenger-install-nginx-moudle 出現如下錯誤 
Java代碼  收藏代碼
  1. StaticContentHandler.c:69: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’  

註釋掉gem包中的 

Java代碼  收藏代碼
  1. Delete these line from ${GEM_HOME}/passenger-2.2.15/ext/nginx/StaticContentHandler.c  
  2.   
  3. if (r->zero_in_uri) {  
  4.   return NGX_DECLINED;  
  5. }  


參見 https://github.com/hmsk/nginx-passenger-centos 

=============================== 
nginx啓動出現錯誤 
Java代碼  收藏代碼
  1. nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory  


進入/lib64目錄中手動鏈接下(服務器是64位的) 
Java代碼  收藏代碼
  1. ln -s libpcre.so.0.0.1 libpcre.so.1  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章