在/var/log/messages会看到如下错误
kernel: php-cgi[26075]: segfault at 000000000000000f rip 00002b8fa54df0b8 rsp 00007fff905e9a40 error 4
原因,开启了php的线程安全模式,与eaccelerator冲突导致的
就是安装时,./configure 加入了--enable-maintainer-zts
解决办法:
安装php时,去掉该参数00
在/var/log/messages会看到如下错误
kernel: php-cgi[26075]: segfault at 000000000000000f rip 00002b8fa54df0b8 rsp 00007fff905e9a40 error 4
原因,开启了php的线程安全模式,与eaccelerator冲突导致的
就是安装时,./configure 加入了--enable-maintainer-zts
解决办法:
安装php时,去掉该参数00
工作中需要用expect来解决一些交互问题,但对expect又不熟悉
幸好同事介绍了autoexpect,它会把你的操作录制成脚本
使用方法是
/usr/bin/autoexpect 你的命令
然后它就会把它录制下来, 存在当前目录scripts.exp
PHP采用php-fpm管理cgi,启动时,如果有加载eaccelerator,就会报Segmentation fault
但端口可以正常起来
程序也可以正常的跑,但看着这个错 ,就是觉得不爽,就像解决它
如果想知道怎么定位是eaccelerator导致的
参考下
用gdb分析段错误(Segmentation fault)
网上找了些资料,终于找到解决办法
原来是我们开启了PHP的线程安全模式,参数是 configure --enable-maintainer-zts
网上说是EA不能在线程安全模式下很好地工作导致的
解决,configure时去掉 --enable-maintainer-zts就OK了
开始前,先看下这篇文章,(猛击此处) Redhat Linux下如何生成core dump文件
看完后,开工
vi /root/.bash_profile
加入ulimit -S -c unlimited > /dev/null 2>&1
保存退出,重新加载配置
source /root/.bash_profile
经研究发现,只要把
/usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
放到脚本里都会报
Segmentation fault
vi /root/test.sh
添加
/usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf
cd /root
sh test.sh
这是它会报Segmentation fault,并在/root下产生一个core.28522文件,这个文件名后面的数字是随机的
现在我们来看下core.28522里面到底是什么内容,需要用到gdb这个工具
yum -y install gdb
gdb使用的方法是
gdb 产生core时执行的命令 core文件
gdb /usr/local/php/bin/php-cgi core.28522
我们在最后会看到
Core was generated by `/usr/local/php/bin/php-cgi --fpm --fpm-config /usr/local/php/etc/php-fpm.conf'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f895e2df0b8 in eaccelerator_clean_shutdown ()
from /usr/local/php/lib/php/extensions/no-debug-zts-20060613/eaccelerator.so
由此,我们定位到是EA导致整个段错误的
有时候nginx,apache,mysql,php编译完了想看看编译参数可以用以下方法
nginx编译参数:
#/usr/local/nginx/sbin/nginx -V
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --prefix=/usr/local/nginx/ --with-http_stub_status_module --with-openssl=/usr/local/openssl
apache编译参数:
# cat /usr/local/apache2/build/config.nice
#! /bin/sh
#
# Created by configure
"./configure" \
"--prefix=/usr/local/apache2" \
"--with-included-apr" \
"--enable-so" \
"--enable-deflate=shared" \
"--enable-expires=shared" \
"--enable-rewrite=shared" \
"--enable-static-support" \
"--disable-userdir" \
"$@"
php编译参数:
# /usr/local/php/bin/php -i |grep configure
Configure Command => './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-config-file-path=/usr/local/php/etc' '--with-mysql=/usr/local/mysql' '--with-libxml-dir=/usr/local/libxml2/bin' '--with-gd=/usr/local/gd2' '--with-jpeg-dir' '--with-png-dir' '--with-bz2' '--with-xmlrpc' '--with-freetype-dir' '--with-zlib-dir'
mysql编译参数:
# cat "/usr/local/mysql/bin/mysqlbug"|grep configure
# This is set by configure
CONFIGURE_LINE="./configure '--prefix=/usr/local/mysql' '--localstatedir=/var/lib/mysql' '--with-comment=Source' '--with-server-suffix=-H863' '--with-mysqld-user=mysql' '--without-debug' '--with-big-tables' '--with-charset=gbk' '--with-collation=gbk_chinese_ci' '--with-extra-charsets=all' '--with-pthread' '--enable-static' '--enable-thread-safe-client' '--with-client-ldflags=-all-static' '--with-mysqld-ldflags=-all-static' '--enable-assembler' '--without-isam' '--without-innodb' '--without-ndb-debug'"
转载自:http://hi.baidu.com/xi4oyu/blog/item/8a0e1ed020e81adb562c8452.html