運維問題彙總(持續更新)

做運維那麼久了,遇到的問題千奇百怪,現決定把大大小小的問題和解決方案做一個彙總。

一是爲了提倡開源精神,二是爲了自己記錄備忘。

問題1:Centos5.5服務器上想掛載一塊windows的移動硬盤。

錯誤:# mount –t ntfs /dev/sdb1 /mnt/
mount: unknown filesystem type ‘ntfs’

解決:

  1. 通過ntfs-3g來解決  
  2. 打開ntfs-3g的下載點http://www.tuxera.com/community/ntfs-3g-download/ 下載最新的版本;  
  3. #下載 :wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2012.1.15.tgz  
  4.  
  5. 解壓,安裝:tar ntfs-3g_ntfsprogs-2012.1.15.tgz  && cd ntfs-3g_ntfsprogs-2012.1.15   &&  ./configure  && make  &&  make install   
  6.  
  7. #查看移動硬盤的屬性: fdisk -l   
  8. #掛載:mount -t ntfs-3g  /dev/sdb1 /mnt/ 

 問題2:如何查看apache加載的模塊?

  1.  #通過幫助得知(/usr/local/apache/bin/apachectl  -h)
  2.  
  3. /usr/local/apache/binapachectl -l  
  4.   -l : list compiled in modules (列出static模塊)  
  5.  
  6.  /usr/local/apache/bin/apachectl -t -D DUMP_MODULES
  7.  
  8.   -t -D DUMP_MODULES : show all loaded modules (包括共享模塊)  
  9. 即http.d中Load Moudles加載的模塊
  10.  
  11. 如下例子:  
  12. [root@sonkwo1 modules]# /usr/local/apache/bin/apachectl  -D DUMP_MODULES  
  13.  
  14. Loaded Modules:  
  15.  core_module (static)  
  16.  authn_file_module (static)  
  17.  authn_default_module (static)  
  18.  authz_host_module (static)  
  19.  authz_groupfile_module (static)  
  20.  authz_user_module (static)  
  21.  authz_default_module (static)  
  22.  auth_basic_module (static)  
  23.  include_module (static)  
  24.  filter_module (static)  
  25.  log_config_module (static)  
  26.  env_module (static)  
  27.  setenvif_module (static)  
  28.  mpm_prefork_module (static)  
  29.  http_module (static)  
  30.  mime_module (static)  
  31.  status_module (static)  
  32.  autoindex_module (static)  
  33.  asis_module (static)  
  34.  cgi_module (static)  
  35.  negotiation_module (static)  
  36.  dir_module (static)  
  37.  actions_module (static)  
  38.  userdir_module (static)  
  39.  alias_module (static)  
  40.  rewrite_module (static)  
  41.  so_module (static)  
  42.  php5_module (shared)  
  43.  rpaf_module (shared) 

 

問題3:啓動apache的時候報:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

  1. 雖然不妨礙使用,但是本着刨根問底的精神,經過查找發現,這個問題應該是沒有在 /$apache/httpd.conf 
  2. 中設定 ServerName。所以apache會用主機上的名稱來取代,首先會去找 /etc/hosts 中有沒有主機的定義。 
  3.  
  4. 所以要解決這個問題可以設定httpd.conf文件中的 ServerName,如下: 
  5. ServerName localhost:80      

問題4:Directory index forbidden by Options directive

apache報錯:Directory index forbidden by Options directive: /var/www/

  1. 在 Apache 中要列出目錄內容需要 mod_autoindex 模塊的支持。  
  2.  
  3. 配置文件的設置方法:  
  4.  
  5. 打開列目錄功能:  
  6. <Directory /path/to/directory> 
  7. Options +Indexes  
  8. </Directory>   
  9. 關閉列目錄功能:  
  10. <Directory /path/to/directory> 
  11. Options -Indexes  
  12. </Directory>   
  13.  
  14.  在使用如 RHEL 或 CentOS 發行版自帶 Apache 的朋友可能會碰到這樣的問題,無法列出網站根目錄下面的內容。其實問題原因很簡單,因爲 Apache 除了會讀取 /etc/httpd/conf/httpd.conf 配置文件外,還會讀取 /etc/httpd/conf.d/ 下以 .conf 結尾的文件。  
  15.  在 /etc/httpd/conf.d/ 下有一個名爲 welcome.conf 的文件,這文件的內容如下:  
  16. #  
  17. # This configuration file enables the default "Welcome"  
  18. # page if there is no default index page present for  
  19. # the root URL.  To disable the Welcome page, comment  
  20. # out all the lines below.  
  21. #  
  22. <LocationMatch "^/+$"> 
  23.     Options -Indexes  
  24.     ErrorDocument 403 /error/noindex.html  
  25. </LocationMatch>   
  26.   我們可以看到文件中去掉了目錄的Indexes屬性,這導致無法列出根目錄的內容。可以通過更改這個文件的後綴名或者註釋掉選項並重新加載配置文件解決該問題。  
  27.   另外如果還有人建議需要一起刪除下面的文件,這個就要看你是否設置DirectoryIndex了。
  28.   rm -f /var/www/error/noindex.html  ← 刪除測試頁 

 

問題5:error while loading shared libraries: xxx.so.x"錯誤的原因和解決辦法

 

  1. 一般我們在Linux下執行某些外部程序的時候可能會提示找不到共享庫的錯誤, 比如:  
  2.  
  3.  
  4. tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory  
  5.  
  6.  
  7. 原因一般有兩個, 一個是操作系統裏確實沒有包含該共享庫(lib*.so.*文件)或者共享庫版本不對, 遇到這種情況那就去網上下載並安裝上即可.   
  8.  
  9. 另外一個原因就是已經安裝了該共享庫, 但執行需要調用該共享庫的程序的時候, 程序按照默認共享庫路徑找不到該共享庫文件.   
  10.  
  11. 所以安裝共享庫後要注意共享庫路徑設置問題, 如下:  
  12.  
  13. 1) 如果共享庫文件安裝到了/lib或/usr/lib目錄下, 那麼需執行一下ldconfig命令  
  14.  
  15. ldconfig命令的用途, 主要是在默認搜尋目錄(/lib和/usr/lib)以及動態庫配置文件/etc/ld.so.conf內所列的目錄下, 搜索出可共享的動態鏈接庫(格式如lib*.so*), 進而創建出動態裝入程序(ld.so)所需的連接和緩存文件. 緩存文件默認爲/etc/ld.so.cache, 此文件保存已排好序的動態鏈接庫名字列表.   
  16.  
  17. 2) 如果共享庫文件安裝到了/usr/local/lib(很多開源的共享庫都會安裝到該目錄下)或其它"非/lib或/usr/lib"目錄下, 那麼在執行ldconfig命令前, 還要把新共享庫目錄加入到共享庫配置文件/etc/ld.so.conf中, 如下:  
  18.  
  19. # cat /etc/ld.so.conf  
  20. include ld.so.conf.d/*.conf  
  21. # echo "/usr/local/lib" >> /etc/ld.so.conf  
  22. # ldconfig  
  23.  
  24. 3) 如果共享庫文件安裝到了其它"非/lib或/usr/lib" 目錄下,  但是又不想在/etc/ld.so.conf中加路徑(或者是沒有權限加路徑). 那可以export一個全局變量LD_LIBRARY_PATH, 然後運行程序的時候就會去這個目錄中找共享庫.   
  25.  
  26. LD_LIBRARY_PATH的意思是告訴loader在哪些目錄中可以找到共享庫. 可以設置多個搜索目錄, 這些目錄之間用冒號分隔開. 比如安裝了一個mysql到/usr/local/mysql目錄下, 其中有一大堆庫文件在/usr/local/mysql/lib下面, 則可以在.bashrc或.bash_profile或shell里加入以下語句即可:  
  27.  
  28. export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH      
  29.  
  30. 一般來講這只是一種臨時的解決方案, 在沒有權限或臨時需要的時候使用.  
  31.  
  32. 4)如果程序需要的庫文件比系統目前存在的村文件版本低,可以做一個鏈接  
  33. 比如:  
  34. error while loading shared libraries: libncurses.so.4: cannot open shared  
  35. object file: No such file or directory  
  36.  
  37. ls /usr/lib/libncu*  
  38. /usr/lib/libncurses.a   /usr/lib/libncurses.so.5  
  39. /usr/lib/libncurses.so  /usr/lib/libncurses.so.5.3  
  40.  
  41. 可見雖然沒有libncurses.so.4,但有libncurses.so.5,是可以向下兼容的  
  42. 建一個鏈接就好了  
  43. ln -s  /usr/lib/libncurses.so.5.3  /usr/lib/libncurses.so.4  

 

問題6:使用scp命令出現   "-bash: scp: command not found" 解決辦法
  1. 安裝yum -y install openssh-clients  
 
問題7:編譯PHP 出現 undefined reference to 'libiconv' 解決辦法
 
  1. 但凡出現類似錯誤,都說明找不到鏈接庫,我們可以嘗試手動在系統中查找
  2. 然後在編譯的時候指定相關目錄即可  
  3.  
  4. #find / -name iconv.h  
  5. #/usr/local/include/iconv.h  
  6.  
  7. 則編譯的時候增加目錄,讓程序能識別出鏈接庫的位置  
  8. --with-iconv=/usr/local/include/ 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章