Apache起動エラー回避

久々に書けた。


先日、色んなVirtualHostが切ってあるサーバに、新たにWebコンテンツの設置をしたのだが・・・


そこで、少しハマりました。


PHP5.1.6で運用しているサーバだったのですが、元Webアプリが、PHP5.2以上で作られているようで、
json_encoding」が無い、とエラーが。


php-json をサックリDLし、インスコ

[user@host ~]$ cd /usr/local/src
[user@host src]$ wget http://www.aurore.net/projects/php-json/php-json-ext-1.2.1.tar.bz2
--21:02:57-- http://www.aurore.net/projects/php-json/php-json-ext-1.2.1.tar.bz2
Resolving www.aurore.net... 72.36.165.74
Connecting to www.aurore.net|72.36.165.74|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 150206 (147K) [application/x-bzip2]
Saving to: `php-json-ext-1.2.1.tar.bz2'

100%[================================================================>] 150,206 172K/s in 0.9s

21:02:59 (172 KB/s) - `php-json-ext-1.2.1.tar.bz2' saved [150206/150206]

[user@host src]$ tar jxf php-json-ext-1.2.1.tar.bz2
[user@host src]$ cd php-json-ext-1.2.1
[user@host php-json-ext-1.2.1]$ cd php-json-ext-1.2.1
[user@host php-json-ext-1.2.1]$ ./configure
checking for gcc... gcc
(snip...)
PATH="$PATH:/sbin" ldconfig -n /usr/local/src/php-json-ext-1.2.1/modules
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/src/php-json-ext-1.2.1/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

[user@host php-json-ext-1.2.1]# su
[root@host php-json-ext-1.2.1]# make install
Installing shared extensions: /usr/lib/php/modules/


でもって、php.ini に、追記。

[root@host php-json-ext-1.2.1]# vi /etc/php.ini
extension=json.so


これでおk。


で、ここで、問題発生なのです。

[root@host php-json-ext-1.2.1]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: Warning: DocumentRoot [/home/ucube-admin/www] does not exist
(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]


すでに80のポートが使われてると?


netstat で見ると、確かにポートが開いている。
しかし、httpd のプロセスは死んでいる。


という事で、どのプロセスが80のポートを使っているかを確認しましょうって事で、
fuserコマンドで、プロセスIDを調べる。

[root@host php-json-ext-1.2.1]# fuser -n tcp 80
80/tcp: 7909


と、プロセスID:7909 のプロセスが、どうやら80のポートを掴んでるようで。
では、そのプロセスは何か?

[root@host php-json-ext-1.2.1]# ps auxww | grep 7909
apache 7909 0.0 0.1 2340 1336 ? Ss Nov18 1:11 bash


bash

うまくApacheの停止が出来なかったのかな?


とりあえず、そのプロセスを殺して、再度確認。

[root@host php-json-ext-1.2.1]# kill -9 7909
[root@host php-json-ext-1.2.1]# fuser -n tcp 80
[root@host php-json-ext-1.2.1]#


おk。


Apache起動。

[root@host php-json-ext-1.2.1]# /etc/rc.d/init.d/httpd start
Starting httpd: [ OK ]


はい、これで完了!!


長時間運用しているサーバだと、こういった事が起こりうるので、
慌てず、騒がず、冷静に対処しましょうって事で。


でわ。