httpd の 起動と確認

次へ

/etc/rc.d/rc.M の 内容確認 と rc.httpd の作成

apachectl

apachectl に ついて

$ /var/data/www/apache2/bin/apachectl ?
Usage: /var/data/www/apache2/bin/httpd [-D name] [-d directory] [-f file]
                                       [-C "directive"] [-c "directive"]
                                       [-k start|restart|graceful|stop]
                                       [-v] [-V] [-h] [-l] [-L] [-t] [-S]
Options:
  -D name           : define a name for use in  directives
  -d directory      : specify an alternate initial ServerRoot
  -f file           : specify an alternate ServerConfigFile
  -C "directive"    : process directive before reading config files
  -c "directive"    : process directive after reading config files
  -e level          : show startup errors of level (see LogLevel)
  -E file           : log startup errors to file
  -v                : show version number
  -V                : show compile settings
  -h                : list available command line options (this page)
  -l                : list compiled in modules
  -L                : list available configuration directives
  -t -D DUMP_VHOSTS : show parsed settings (currently only vhost settings)
  -S                : a synonym for -t -D DUMP_VHOSTS
  -t                : run syntax check for config files

さて httpd の 起動について ”/etc/rc.d/rc.M”で httpd の 起動部分を 確認しておきましょう

sv:/etc/rc.d# cat rc.M
....
# Start Apache.
if [ -x /etc/rc.d/rc.httpd ]; then
    echo -n " Apache"
    /etc/rc.d/rc.httpd > /dev/null 2>&1
fi
....

rc.httpd を作成すれば良いようです

rc.httpd

rc.httpd を作成

sv:/etc/rc.d# vi rc.httpd
sv:/etc/rc.d# cat rc.httpd 
#!/bin/sh
    
    # start httpd
    
    case "$1" in
        start)
          /var/data/www/apache2/bin/apachectl start
          ;;
        stop)
          /var/data/www/apache2/bin/apachectl stop
          ;;
        restart)
          /var/data/www/apache2/bin/apachectl restart
          ;;
        *)
          echo "Usage: rc.httpd [start|stop|restart]"
          ;;
    esac
sv:/etc/rc.d# ls -l rc.httpd 
-rw-r--r--    1 root     root          315 Sep 24 16:13 rc.httpd
sv:/etc/rc.d# chmod 755 rc.httpd 
sv:/etc/rc.d# ls -l rc.httpd 
-rwxr-xr-x    1 root     root          315 Sep 24 16:13 rc.httpd*

この場合 rc.M も 一部修正しましょう

rc.M

rc.M を修正

sv:/etc/rc.d# cp rc.M 20070924_rc.M_org
sv:/etc/rc.d# vi rc.M
sv:/etc/rc.d# diff -s rc.M 20070924_rc.M_org 
230c230
<     /etc/rc.d/rc.httpd  start > /dev/null 2>&1
---
>     /etc/rc.d/rc.httpd > /dev/null 2>&1

shutdown -r now

再起動確認

sv:/etc/rc.d# shutdown -r now

Broadcast message from root (pts/0) (Mon Sep 24 16:33:17 2007):

The system is going down for reboot NOW!
sv:/var/log# Connection to 192.168.0.9 closed by remote host.
Connection to 192.168.0.9 closed.

起動を確認

さて 無事 起動しているか 確認しましょう

# cd /var/data/www/apache2/logs/
sv:/var/data/www/apache2/logs# ls -l | sed 1d
-rw-r--r--    1 root     root            0 Sep 24 16:32 access_log
-rw-r--r--    1 root     root           98 Sep 24 16:34 error_log
-rw-r--r--    1 root     root            4 Sep 24 16:34 httpd.pid
sv:/var/data/www/apache2/logs# cat error_log 
[Mon Sep 24 16:34:50 2007] [notice] Apache/2.0.61 (Unix) configured\
 -- resuming normal operations
http://192.168.0.9/

に ブラウザにてアクセスして 見える事を確認、また telnet を 使って

fdopstm@lx:~$ telnet 192.168.0.9 80
Trying 192.168.0.9...
Connected to 192.168.0.9.
Escape character is '^]'.
GET / HTTP/1.0 <CR><CR>

HTTP/1.1 200 OK
Date: Mon, 24 Sep 2007 08:08:18 GMT
Server: Apache/2.0.61 (Unix)
Content-Location: index.html.en
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Sun, 21 Nov 2004 14:35:21 GMT
ETag: "9e7b2-5b0-a64a7c40;9e7c8-961-a64a7c40"
Accept-Ranges: bytes
Content-Length: 1456
Connection: close
Content-Type: text/html
Content-Language: en
Expires: Mon, 24 Sep 2007 08:08:18 GMT

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test Page for Apache Installation</title>
</head>
<!-- Background white, links blue (unvisited), navy (visited), red
(active) -->
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
vlink="#000080" alink="#FF0000">
<p>If you can see this, it means that the installation of the <a
href="http://www.apache.org/foundation/preFAQ.html">Apache web
server</a> software on this system was successful. You may now add
content to this directory and replace this page.</p>

<hr width="50%" size="8" />
<h2 align="center">Seeing this instead of the website you
expected?</h2>

<p>This page is here because the site administrator has changed the
configuration of this web server. Please <strong>contact the person
responsible for maintaining this server with questions.</strong>
The Apache Software Foundation, which wrote the web server software
this site administrator is using, has nothing to do with
maintaining this site and cannot help resolve configuration
issues.</p>

<hr width="50%" size="8" />
<p>The Apache <a href="manual/">documentation</a> has been included
with this distribution.</p>

<p>You are free to use the image below on an Apache-powered web
server. Thanks for using Apache!</p>

<div align="center"><img src="apache_pb.gif" alt="" /></div>
</body>
</html>

Connection closed by foreign host.

受信した方では ( error_log は クリヤー しましたが )

sv:/var/data/www/apache2/logs# ls -l | sed 1d
-rw-r--r--    1 root     root           71 Sep 24 17:08 access_log
-rw-r--r--    1 root     root            0 Sep 24 17:02 error_log
-rw-r--r--    1 root     root            4 Sep 24 16:34 httpd.pid
sv:/var/data/www/apache2/logs# cat access_log 
192.168.0.5 - - [24/Sep/2007:17:08:18 +0900] "GET / HTTP/1.0" 200 1456
sv:/var/data/www/apache2/logs# cat httpd.pid 
214

ps aux

”ps aux”にて確認しておきましょう

# ps aux | grep http
root   214 0.0 0.9  3680 1756 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 217 0.0 1.0  3836 1948 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 218 0.0 0.9  3844 1896 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 219 0.0 0.9  3836 1904 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 220 0.0 0.9  3844 1868 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 221 0.0 0.9  3836 1912 ? S 16:34 0:00 /var/data/www/apache2/bin/httpd -k start
apache 349 0.0 0.9  3712 1812 ? S 16:39 0:00 /var/data/www/apache2/bin/httpd -k start

補足

要求した 側にて

fdopstm@lx:~$ telnet 192.168.0.9 80
Trying 192.168.0.9...
Connected to 192.168.0.9.
Escape character is '^]'.
GET / HTTP/1.1<CR><CR>

HTTP/1.1 400 Bad Request
Date: Mon, 24 Sep 2007 08:26:46 GMT
Server: Apache/2.0.61 (Unix)
Content-Length: 311
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.0.61 (Unix) Server at www.nyanta.no-ip.info Port 80</address>
</body></html>
Connection closed by foreign host.

受信側

sv:/var/data/www/apache2/logs# ls -l | sed 1d
-rw-r--r--    1 root     root           70 Sep 24 17:26 access_log
-rw-r--r--    1 root     root          133 Sep 24 17:26 error_log
-rw-r--r--    1 root     root            4 Sep 24 16:34 httpd.pid
# cat error_log 
[Mon Sep 24 17:26:48 2007] [error] [client 192.168.0.5] \
client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /
sv:/var/data/www/apache2/logs# cat access_log 
192.168.0.5 - - [24/Sep/2007:17:26:46 +0900] "GET / HTTP/1.1" 400 311

まあこういうものでしょう

にゃんたろう 拝!

2007年 9月24日 (月) 21:12:24 JST 作成


次へ

httpd の 起動と確認

Copyright © 2007. nyantarou All Rights Reserved.