但是,最近重启了一下apache,结果报错:
/etc/init.d/httpd: line 81: 27835 Segmentation fault $HTTPD "$@"
如何定位问题?我们需要把coredump搞出来,用gdb进行调试,看能不能把问题定位出来。 关于coredump:
coredump又叫核心转储, 当程序运行过程中发生异常, 程序异常退出时, 由操作系统把程序当前的内存状况存储在一个core文件中, 叫coredump。产生coredump的条件:
ulimit -c unlimited/lnmp/apache/bin/httpd -k start
就会在当前的目录下生成一个”core+进程id“的dump包 实际上,在Apache的配置文件中有个配置选项,可以用来控制Apache使用的内核转储目录:
CoreDumpDirectory "/tmp/apache-gdb-dump"
但是,我设置了以后,不起作用,求大神解惑啊。 然后,用gdb进行调试:
gdb /lnamp/apache/bin/httpd core.28051
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)Copyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. Type "show copying"and "show warranty" for details.This GDB was configured as "x86_64-redhat-linux-gnu".For bug reporting instructions, please see:...Reading symbols from /lnmp/apache/bin/httpd...done.[New Thread 28051].......warning: no loadable sections found in added symbol-file system-supplied DSO at 0x7ffee7794000Core was generated by `/lnmp/apache/bin/httpd -k start'.Program terminated with signal 11, Segmentation fault.#0 memcpy () at ../sysdeps/x86_64/memcpy.S:267267 repMissing separate debuginfos, use: debuginfo-install libidn-1.18-2.el6.x86_64
报了一个Missin separate debuginfos, use: debuginfo-install libidn-1.18-2.el6.x86_64的错误,但是没有找到解决方法。
接着执行:(gdb) bt full #调用栈信息......#6 0x00007f52c4e6651a in zend_startup_modules () at /software/git_download/php-7.0.0/Zend/zend_API.c:1967No locals.#7 0x00007f52c4df016d in php_module_startup (sf=, additional_modules=, num_additional_modules=)at /software/git_download/php-7.0.0/main/main.c:2194zuf = {error_function = 0x7f52c4aaffd6 , printf_function = 0x7f52c4def8e0 , write_function = 0x7f52c4dedff0 ,fopen_function = 0x7f52c4dee370 , message_handler = 0x7f52c4aafbf3 , block_interruptions = 0, unblock_interruptions = 0,get_configuration_directive = 0x7f52c4dee360 , ticks_function = 0x7f52c4dffd50 , on_timeout = 0x7f52c4def420 ,stream_open_function = 0x7f52c4def650 , vspprintf_function = 0x7f52c4df4120 , vstrpprintf_function = 0x7f52c4df3fe0 ,getenv_function = 0x7f52c4df7830 , resolve_path_function = 0x7f52c4dee300 }zuv = {import_use_extension = 0x7f52c53fc770 ".php", import_use_extension_length = 4, html_errors = 1 '\001'}retval = 0php_os = 0x7f52c541c6f7 "Linux"module = #8 0x00007f52c2621be5 in php_apache2_startup (sapi_module=) at /software/php-5.6.5/sapi/apache2handler/sapi_apache2.c:348No locals.
从上面的信息中可以看出调用了两个php扩展,一个是php-7的,一个是php-5.6.5的,然后看了httpd的配置文件,结果配置了两个php模块:LoadModule php7_module modules/libphp7.soLoadModule php5_module modules/libphp5.so
,去掉一个扩展后,apache启动正常。 应该是安装了php7后,又往httpd的配置文件中加入了php7的扩展。
另外在Apache主配置文件中/usr/local/apache/conf/httpd.conf里的php_modules栏里也会有两个,需要注销掉一个。
出处:https://www.bhqb.org/blog/post-695.html