运维问题汇总(持续更新)

做运维那么久了,遇到的问题千奇百怪,现决定把大大小小的问题和解决方案做一个汇总。

一是为了提倡开源精神,二是为了自己记录备忘。

问题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/ 

 

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