运维小issue
做运维那么久了,遇到的问题千奇百怪,现决定把大大小小的问题和解决方案做一个汇总。
一是为了提倡分享精神,二是为了自己记录备忘。
错误:问题1:Centos5.5服务器上想挂载一块windows的移动硬盘
# mount –t ntfs /dev/sdb1 /mnt/ mount: unknown filesystem type ‘ntfs’解决:
通过ntfs-3g来解决 打开ntfs-3g的下载点http://www.tuxera.com/community/ntfs-3g-download/ 下载最新的版本; #下载 :wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2012.1.15.tgz 解压,安装:tar ntfs-3g_ntfsprogs-2012.1.15.tgz && cd ntfs-3g_ntfsprogs-2012.1.15 && ./configure && make && make install #查看移动硬盘的属性: fdisk -l #挂载:mount -t ntfs-3g /dev/sdb1 /mnt/
问题2:如何查看apache加载的模块
#通过帮助得知(/usr/local/apache/bin/apachectl -h)
/usr/local/apache/binapachectl -l
-l : list compiled in modules (列出static模块)
/usr/local/apache/bin/apachectl -t -D DUMP_MODULES
-t -D DUMP_MODULES : show all loaded modules (包括共享模块)
即http.d中Load Moudles加载的模块
如下例子:
[root@sonkwo1 modules]# /usr/local/apache/bin/apachectl -D DUMP_MODULES
Loaded Modules:
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
env_module (static)
setenvif_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
rewrite_module (static)
so_module (static)
php5_module (shared)
rpaf_module (shared)
问题3:启动apache的时候报:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
虽然不妨碍使用,但是本着刨根问底的精神,经过查找发现,这个问题应该是没有在 /$apache/httpd.conf 中设定 ServerName。所以apache会用主机上的名称来取代,首先会去找 /etc/hosts 中有没有主机的定义。 所以要解决这个问题可以设定httpd.conf文件中的 ServerName,如下: ServerName localhost:80
apache报错:Directory index forbidden by Options directive: /var/www/问题4:Directory index forbidden by Options directive
在 Apache 中要列出目录内容需要 mod_autoindex 模块的支持。 配置文件的设置方法: 打开列目录功能:Options +Indexes 关闭列目录功能:Options -Indexes 在使用如 RHEL 或 CentOS 发行版自带 Apache 的朋友可能会碰到这样的问题,无法列出网站根目录下面的内容。其实问题原因很简单,因为 Apache 除了会读取 /etc/httpd/conf/httpd.conf 配置文件外,还会读取 /etc/httpd/conf.d/ 下以 .conf 结尾的文件。 在 /etc/httpd/conf.d/ 下有一个名为 welcome.conf 的文件,这文件的内容如下: # # This configuration file enables the default "Welcome" # page if there is no default index page present for # the root URL. To disable the Welcome page, comment # out all the lines below. #Options -Indexes ErrorDocument 403 /error/noindex.html 我们可以看到文件中去掉了目录的Indexes属性,这导致无法列出根目录的内容。可以通过更改这个文件的后缀名或者注释掉选项并重新加载配置文件解决该问题。 另外如果还有人建议需要一起删除下面的文件,这个就要看你是否设置DirectoryIndex了。 rm -f /var/www/error/noindex.html ← 删除测试页
问题5:error while loading shared libraries: xxx.so.x"错误的原因和解决办法
一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: tmux: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory 原因一般有两个, 一个是操作系统里确实没有包含该共享库(lib[i].so.[/i]文件)或者共享库版本不对, 遇到这种情况那就去网上下载并安装上即可. 另外一个原因就是已经安装了该共享库, 但执行需要调用该共享库的程序的时候, 程序按照默认共享库路径找不到该共享库文件. 所以安装共享库后要注意共享库路径设置问题, 如下: 1) 如果共享库文件安装到了/lib或/usr/lib目录下, 那么需执行一下ldconfig命令 ldconfig命令的用途, 主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下, 搜索出可共享的动态链接库(格式如lib[i].so[/i]), 进而创建出动态装入程序(ld.so)所需的连接和缓存文件. 缓存文件默认为/etc/ld.so.cache, 此文件保存已排好序的动态链接库名字列表. 2) 如果共享库文件安装到了/usr/local/lib(很多开源的共享库都会安装到该目录下)或其它"非/lib或/usr/lib"目录下, 那么在执行ldconfig命令前, 还要把新共享库目录加入到共享库配置文件/etc/ld.so.conf中, 如下: # cat /etc/ld.so.conf include ld.so.conf.d/*.conf # echo "/usr/local/lib" >> /etc/ld.so.conf # ldconfig 3) 如果共享库文件安装到了其它"非/lib或/usr/lib" 目录下, 但是又不想在/etc/ld.so.conf中加路径(或者是没有权限加路径). 那可以export一个全局变量LD_LIBRARY_PATH, 然后运行程序的时候就会去这个目录中找共享库. LD_LIBRARY_PATH的意思是告诉loader在哪些目录中可以找到共享库. 可以设置多个搜索目录, 这些目录之间用冒号分隔开. 比如安装了一个mysql到/usr/local/mysql目录下, 其中有一大堆库文件在/usr/local/mysql/lib下面, 则可以在.bashrc或.bash_profile或shell里加入以下语句即可: export LD_LIBRARY_PATH=/usr/local/mysql/lib:$LD_LIBRARY_PATH 一般来讲这只是一种临时的解决方案, 在没有权限或临时需要的时候使用. 4)如果程序需要的库文件比系统目前存在的村文件版本低,可以做一个链接 比如: error while loading shared libraries: libncurses.so.4: cannot open shared object file: No such file or directory ls /usr/lib/libncu* /usr/lib/libncurses.a /usr/lib/libncurses.so.5 /usr/lib/libncurses.so /usr/lib/libncurses.so.5.3 可见虽然没有libncurses.so.4,但有libncurses.so.5,是可以向下兼容的 建一个链接就好了 ln -s /usr/lib/libncurses.so.5.3 /usr/lib/libncurses.so.4
问题6:使用scp命令出现 "-bash: scp: command not found" 解决办法
# yum -y install openssh-clients
问题7:编译PHP 出现 undefined reference to 'libiconv' 解决办法
但凡出现类似错误,都说明找不到链接库,我们可以尝试手动在系统中查找 然后在编译的时候指定相关目录即可 #find / -name iconv.h #/usr/local/include/iconv.h 则编译的时候增加目录,让程序能识别出链接库的位置 --with-iconv=/usr/local/include/原文地址