apache无法启动,现象:
浏览器打开localhost,一直在等待中。查看apache2的error日志,看到:
tail -100 /var/log/apache2/error.log...[Mon Feb 15 11:25:32 2016] [error] [client 10.0.0.163] Negotiation: discovered file(s) matching request: /var/www/index.html (None could be negotiated).11:25:32: Error: Unable to initialize GTK+, is DISPLAY set properly?(apache2:6670): GLib-GObject-WARNING **: invalid (NULL) pointer instance(apache2:6670): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed(apache2:6670): GLib-GObject-WARNING **: invalid (NULL) pointer instance(apache2:6670): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_screen_get_default_colormap: assertion `GDK_IS_SCREEN (screen)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_colormap_get_visual: assertion `GDK_IS_COLORMAP (colormap)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_screen_get_default_colormap: assertion `GDK_IS_SCREEN (screen)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_screen_get_root_window: assertion `GDK_IS_SCREEN (screen)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_screen_get_root_window: assertion `GDK_IS_SCREEN (screen)' failed(apache2:6670): Gdk-CRITICAL **: IA__gdk_window_new: assertion `GDK_IS_WINDOW (parent)' failed[Mon Feb 15 11:25:32 2016] [notice] child pid 6666 exit signal Segmentation fault (11)[Mon Feb 15 11:25:32 2016] [notice] child pid 6667 exit signal Segmentation fault (11)[Mon Feb 15 11:25:32 2016] [notice] child pid 6668 exit signal Segmentation fault (11)[Mon Feb 15 11:25:32 2016] [notice] child pid 6669 exit signal Segmentation fault (11)[Mon Feb 15 11:25:32 2016] [notice] child pid 6670 exit signal Segmentation fault (11)[Mon Feb 15 11:29:11 2016] [notice] caught SIGTERM, shutting down[Mon Feb 15 11:29:12 2016] [notice] Apache/2.2.22 (Debian) PHP/5.4.45-0+deb7u2 configured -- resuming normal operations
查看apache2的php模块:
shen@debian:~$ ls -lrt /etc/php5/apache2/conf.d/总用量 0lrwxrwxrwx 1 root root 25 8月 31 13:36 10-pdo.ini -> ../mods-available/pdo.inilrwxrwxrwx 1 root root 27 8月 31 13:36 20-mysql.ini -> ../mods-available/mysql.inilrwxrwxrwx 1 root root 28 8月 31 13:36 20-mysqli.ini -> ../mods-available/mysqli.inilrwxrwxrwx 1 root root 31 8月 31 13:36 20-pdo_mysql.ini -> ../mods-available/pdo_mysql.inilrwxrwxrwx 1 root root 24 9月 5 10:02 20-gd.ini -> ../mods-available/gd.inilrwxrwxrwx 1 root root 28 9月 5 10:02 20-mcrypt.ini -> ../mods-available/mcrypt.inilrwxrwxrwx 1 root root 27 9月 9 09:41 20-redis.ini -> ../mods-available/redis.inilrwxrwxrwx 1 root root 26 9月 21 13:40 20-curl.ini -> ../mods-available/curl.inilrwxrwxrwx 1 root root 28 1月 10 14:39 20-xdebug.ini -> ../mods-available/xdebug.inilrwxrwxrwx 1 root root 27 2月 4 13:14 20-cairo.ini -> ../mods-available/cairo.inilrwxrwxrwx 1 root root 31 2月 4 13:53 20-wxwidgets.ini -> ../mods-available/wxwidgets.ini
最新的两个php模块cairo和wxwidgets是在安装wxPHP时引入的,只有cli-php才需要,apache-php不需要。
但是当前情况下,cli-php和apache-php的模块列表是一样的。shen@debian:~$ ls -l /etc/php5/cli/总用量 64lrwxrwxrwx 1 root root 9 8月 16 2015 conf.d -> ../conf.d-rw-r--r-- 1 root root 64017 8月 16 2015 php.inishen@debian:~$ shen@debian:~$ shen@debian:~$ ls -l /etc/php5/apache2/总用量 64lrwxrwxrwx 1 root root 9 8月 16 2015 conf.d -> ../conf.d-rw-r--r-- 1 root root 64340 9月 5 15:25 php.inishen@debian:~$ ls -l /etc/php5/cli/总用量 64lrwxrwxrwx 1 root root 9 8月 16 2015 conf.d -> ../conf.d-rw-r--r-- 1 root root 64017 8月 16 2015 php.inishen@debian:~$ ls -l /etc/php5/总用量 20drwxr-xr-x 2 root root 4096 1月 10 16:16 apache2drwxr-xr-x 2 root root 4096 8月 31 13:36 cgidrwxr-xr-x 2 root root 4096 2月 4 13:12 clidrwxr-xr-x 2 root root 4096 2月 4 13:53 conf.ddrwxr-xr-x 2 root root 4096 2月 4 13:52 mods-available
解决方法: cli-php和apache-php的模块列表分开设置:
shen@debian:~$ cd /etc/php5/apache2/shen@debian:/etc/php5/apache2$ sudo rm -f conf.dshen@debian:/etc/php5/apache2$ sudo cp -rL ../conf.d/ .shen@debian:/etc/php5/apache2$ ls -l conf.d/总用量 44-rw-r--r-- 1 root root 66 2月 15 14:14 10-pdo.ini-rw-r--r-- 1 root root 70 2月 15 14:14 20-cairo.ini-rw-r--r-- 1 root root 68 2月 15 14:14 20-curl.ini-rw-r--r-- 1 root root 64 2月 15 14:14 20-gd.ini-rw-r--r-- 1 root root 72 2月 15 14:14 20-mcrypt.ini-rw-r--r-- 1 root root 71 2月 15 14:14 20-mysqli.ini-rw-r--r-- 1 root root 70 2月 15 14:14 20-mysql.ini-rw-r--r-- 1 root root 74 2月 15 14:14 20-pdo_mysql.ini-rw-r--r-- 1 root root 71 2月 15 14:14 20-redis.ini-rw-r--r-- 1 root root 78 2月 15 14:14 20-wxwidgets.ini-rw-r--r-- 1 root root 174 2月 15 14:14 20-xdebug.inishen@debian:/etc/php5/apache2$ sudo rm -f conf.d/20-wxwidgets.inishen@debian:/etc/php5/apache2$ sudo rm -f conf.d/20-cairo.ini shen@debian:/etc/php5/apache2$ ls -l conf.d/总用量 36-rw-r--r-- 1 root root 66 2月 15 14:14 10-pdo.ini-rw-r--r-- 1 root root 68 2月 15 14:14 20-curl.ini-rw-r--r-- 1 root root 64 2月 15 14:14 20-gd.ini-rw-r--r-- 1 root root 72 2月 15 14:14 20-mcrypt.ini-rw-r--r-- 1 root root 71 2月 15 14:14 20-mysqli.ini-rw-r--r-- 1 root root 70 2月 15 14:14 20-mysql.ini-rw-r--r-- 1 root root 74 2月 15 14:14 20-pdo_mysql.ini-rw-r--r-- 1 root root 71 2月 15 14:14 20-redis.ini-rw-r--r-- 1 root root 174 2月 15 14:14 20-xdebug.ini
cli-php下保留全部php模块:
shen@debian:/etc/php5/apache2$ ls -l ../cli/conf.d/总用量 0lrwxrwxrwx 1 root root 25 8月 31 13:36 10-pdo.ini -> ../mods-available/pdo.inilrwxrwxrwx 1 root root 27 2月 4 13:14 20-cairo.ini -> ../mods-available/cairo.inilrwxrwxrwx 1 root root 26 9月 21 13:40 20-curl.ini -> ../mods-available/curl.inilrwxrwxrwx 1 root root 24 9月 5 10:02 20-gd.ini -> ../mods-available/gd.inilrwxrwxrwx 1 root root 28 9月 5 10:02 20-mcrypt.ini -> ../mods-available/mcrypt.inilrwxrwxrwx 1 root root 28 8月 31 13:36 20-mysqli.ini -> ../mods-available/mysqli.inilrwxrwxrwx 1 root root 27 8月 31 13:36 20-mysql.ini -> ../mods-available/mysql.inilrwxrwxrwx 1 root root 31 8月 31 13:36 20-pdo_mysql.ini -> ../mods-available/pdo_mysql.inilrwxrwxrwx 1 root root 27 9月 9 09:41 20-redis.ini -> ../mods-available/redis.inilrwxrwxrwx 1 root root 31 2月 4 13:53 20-wxwidgets.ini -> ../mods-available/wxwidgets.inilrwxrwxrwx 1 root root 28 1月 10 14:39 20-xdebug.ini -> ../mods-available/xdebug.ini
重启apache2:
shen@debian:/etc/php5/apache2$ sudo /etc/init.d/apache2 restart[ ok ] Restarting web server: apache2 ... waiting .
浏览器打开localhost,完美恢复。