|
|
1行目: |
1行目: |
| ==準備== | | ==目的== |
| <ul>
| | |
| <li>[https://httpd.apache.org/ Apache HTTP Server]
| | ==準備・参考== |
| </li> | | <syntaxhighlight lang="bash"> |
| <li>[http://www.apache.org/ Apacheソフトウェア財団]
| | [root@XXXXX ~]# yum install perl-ExtUtils-MakeMaker |
| </li> | | </syntaxhighlight> |
| </ul>
| | |
| <br>
| |
| ==インストール== | | ==インストール== |
| <ol> | | <ol> |
| <li>ソースの取得<br> | | <li>'''ソースの取得''' |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| [root@XXXXX ~]# wget -P /usr/local/src http://www.ring.gr.jp/archives/net/apache/httpd/httpd-2.2.21.tar.gz | | [root@XXXXX ~]# wget -P /usr/local/src https://git-core.googlecode.com/files/git-1.8.2.1.tar.gz |
| </syntaxhighlight> | | </syntaxhighlight > |
| /usr/local/srcにhttpd-2.2.21.tar.gzを取得。
| | <br> |
| <br><br>
| |
| </li> | | </li> |
| <li>ソースの解凍<br> | | <li>'''ソースの解凍''' |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| [root@XXXXX ~]# cd /usr/local/src | | [root@XXXXX ~]# cd /usr/local/src |
| [root@XXXXX ~]# tar zxvf httpd-2.2.21.tar.gz | | [root@XXXXX ~]# tar zxvf git-1.8.2.1.tar.gz |
| </syntaxhighlight>
| | </syntaxhighlight > |
| /usr/local/srcにhttpd-2.2.21フォルダが作成される。
| |
| <br><br>
| |
| </li>
| |
| <li>APR(Apache Portable Runtime)のインストール
| |
| <ol type="i">
| |
| <li>apr(1.4.5)<br>
| |
| ([[apr-1.4.5のconfigureヘルプ|configureのヘルプ]])
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# cd /usr/local/src/httpd-2.2.21/srclib/apr
| |
| [root@XXXXX ~]# ./configure --prefix=/usr/local/httpd-2.2.21/apr
| |
| [root@XXXXX ~]# make
| |
| [root@XXXXX ~]# make install
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| <li>apr-util(1.3.12)<br>
| |
| ([[apr-util-1.3.12のconfigureヘルプ|configureのヘルプ]])
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# cd /usr/local/src/httpd-2.2.21/srclib/apr-util
| |
| [root@XXXXX ~]# ./configure --prefix=/usr/local/httpd-2.2.21/apr-util --with-apr=/usr/local/httpd-2.2.21/apr
| |
| [root@XXXXX ~]# make
| |
| [root@XXXXX ~]# make install
| |
| </syntaxhighlight> | |
| <br> | | <br> |
| </li> | | </li> |
| </ol>
| | <li>'''コンパイル設定'''<br /> |
| <li>コンパイル設定<br> | | ([[git-1.8.2.1のconfigureヘルプ]]) |
| ([[Apache 2.2.21のconfigureヘルプ|configureのヘルプ]])
| |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| [root@XXXXX ~]# cd /usr/local/src/httpd-2.2.21 | | [root@XXXXX ~]# cd git-1.8.2.1 |
| [root@XXXXX ~]# ./configure \ | | [root@XXXXX ~]# ./configure \ |
| > --prefix=/usr/local/httpd-2.2.21 \ | | > --prefix=/usr/local |
| > --enable-so \
| | </syntaxhighlight > |
| > --enable-rewrite=shared \
| |
| > --enable-dav=shared \
| |
| > --enable-dav-fs=shared \
| |
| > --enable-dav-lock=shared \
| |
| > --enable-ssl=shared \
| |
| > --with-ssl=/usr/local/ssl/ \
| |
| > --with-apr=/usr/local/httpd-2.2.21/apr \
| |
| > --with-apr-util=/usr/local/httpd-2.2.21/apr-util
| |
| </syntaxhighlight> | |
| <br> | | <br> |
| </li> | | </li> |
| <li>インストール | | <li>'''インストール''' |
| <syntaxhighlight lang="bash"> | | <syntaxhighlight lang="bash"> |
| [root@XXXXX ~]# make | | [root@XXXXX ~]# make |
| [root@XXXXX ~]# make install | | [root@XXXXX ~]# make install |
| </syntaxhighlight> | | </syntaxhighlight > |
| <br>
| |
| </li>
| |
| <li>シンボリックリンクの作成
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# ln -s /usr/local/httpd-2.2.21 /usr/local/apache2
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li> | | </li> |
| </ol> | | </ol> |
|
| |
| ==初期設定==
| |
|
| |
| ====apacheユーザーの作成====
| |
| apache専用のユーザーを作成する。ユーザー名はapache。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# groupadd apache
| |
| [root@XXXXX ~]# useradd -g apache apache
| |
| </syntaxhighlight>
| |
| <br>
| |
|
| |
| ====httpd.confの設定====
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /usr/local/apache2/conf/httpd.conf
| |
| </syntaxhighlight>
| |
| <br>
| |
| <ul>
| |
| <li>ユーザーとグループの変更
| |
| <syntaxhighlight lang="bash">
| |
| User daemon
| |
| Group daemon
| |
| ↓
| |
| User apache
| |
| Group apache
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| <li>サーバー名の設定
| |
| <syntaxhighlight lang="bash">
| |
| ServerName www.example.com:80
| |
| ↓
| |
| ServerName XXXXXXXXXXX:80
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| </ul>
| |
|
| |
| ==起動==
| |
| 下記のコマンドで起動、停止、再起動を行う
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# /usr/local/apache2/bin/apachectl start ← 起動
| |
| [root@XXXXX ~]# /usr/local/apache2/bin/apachectl stop ← 停止
| |
| [root@XXXXX ~]# /usr/local/apache2/bin/apachectl restart ← 再起動
| |
| </syntaxhighlight>
| |
| <br>
| |
| ==動作確認==
| |
| http,httpsでそれぞれアクセスし「It works!」が表示されればOK。
| |
| <br>
| |
| ==自動起動設定==
| |
| <ol>
| |
| <li>起動スクリプトのコピー
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# cp /usr/local/src/httpd-2.2.21/build/rpm/httpd.init /etc/rc.d/init.d/httpd
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| <li>起動スクリプトの編集
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /etc/rc.d/init.d/httpd
| |
| </syntaxhighlight>
| |
| <br>
| |
| パスの変更
| |
| <syntaxhighlight lang="vim">
| |
| httpd=${HTTPD-/usr/sbin/httpd}
| |
| ↓
| |
| httpd=${HTTPD-/usr/local/apache2/bin/httpd}
| |
| </syntaxhighlight>
| |
| <br>
| |
| (~check13()の中~)
| |
| <syntaxhighlight lang="vim">
| |
| CONFFILE=/etc/httpd/conf/httpd.conf
| |
| ↓
| |
| CONFFILE=/usr/local/apache2/conf/httpd.conf
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| <li>実行権限を与えて自動起動設定
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# chmod 755 /etc/rc.d/init.d/httpd
| |
| [root@XXXXX ~]# chkconfig --add httpd
| |
| [root@XXXXX ~]# chkconfig httpd on
| |
| [root@XXXXX ~]# chkconfig --list httpd
| |
| httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
| |
| </syntaxhighlight>
| |
| <br>
| |
| </li>
| |
| </ol>
| |
| <br>
| |
|
| |
| ==他==
| |
| ====STOPに失敗する====
| |
| 上記の手順でインストールするとhttpdスクリプトでstopさせる時に失敗してしまう。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# /etc/rc.d/init.d/httpd start
| |
| httpd を起動中: [ OK ]
| |
| [root@XXXXX ~]# /etc/rc.d/init.d/httpd stop
| |
| httpd を停止中: [失敗]
| |
| </syntaxhighlight>
| |
| pidファイルの位置が違っているのが原因みたい。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# /etc/rc.d/init.d/httpd start
| |
| httpd を起動中: [ OK ]
| |
|
| |
| [root@XXXXX ~]# find / -name *.pid
| |
| /var/run/abrtd.pid
| |
| /var/run/syslogd.pid
| |
| /var/run/sshd.pid
| |
| /var/run/crond.pid
| |
| /var/run/messagebus.pid
| |
| /var/run/haldaemon.pid
| |
| /usr/local/httpd-2.2.21/logs/httpd.pid ← ここにpidファイルが作成されている
| |
| </syntaxhighlight>
| |
| httpd起動スクリプトでは、
| |
| <syntaxhighlight lang="vim">
| |
| pidfile=${PIDFILE-/var/log/httpd/${prog}.pid}
| |
| </syntaxhighlight>
| |
| と記述されている。<br>
| |
| [http://httpd.apache.org/docs/2.2/ Apache HTTP サーバ バージョン 2.2 ドキュメント]によるとpid作成先を設定するディレクティブは'''PidFile'''でデフォルトは'''logs/httpd.pid'''になるみたい。<br>
| |
| httpd.confには記述が無いので追加する。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /usr/local/apache2/conf/httpd.conf
| |
|
| |
| PidFile /var/run/httpd.pid ← ServerRootの次ぐらいの行に追加
| |
| </syntaxhighlight>
| |
| httpd起動スクリプトも修正する。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /etc/rc.d/init.d/httpd
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="vim">
| |
| # pidfile=${PIDFILE-/var/log/httpd/${prog}.pid} ← コメントアウト
| |
| pidfile=${PIDFILE-/var/run/httpd.pid} ← 追加
| |
| </syntaxhighlight>
| |
| テスト
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# /etc/rc.d/init.d/httpd start
| |
| httpd を起動中: [ OK ]
| |
| [root@XXXXX ~]# find / -name *.pid
| |
| /var/run/abrtd.pid
| |
| /var/run/syslogd.pid
| |
| /var/run/sshd.pid
| |
| /var/run/crond.pid
| |
| /var/run/httpd.pid ←
| |
| /var/run/messagebus.pid
| |
| /var/run/haldaemon.pid
| |
|
| |
| [root@XXXXX ~]# /etc/rc.d/init.d/httpd stop
| |
| httpd を停止中: [ OK ]
| |
| </syntaxhighlight>
| |
| <br>
| |
|
| |
| ====STOPに失敗する その2====
| |
| conf/extra/httpd-mpm.confにPidFileディレクティブの記述があるがソースからコンパイルするとhttpd.confでextra/httpd-mpm.confがincludeされない(?)ようである。httpd-mpm.confでPidFileのパスを修正し、httpd.confでextra/httpd-mpm.confをincludeさせてもOKかと。
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /usr/local/apache2/conf/extra/httpd-mpm.conf
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="vim">
| |
| #PidFile "logs/httpd.pid"
| |
| ↓
| |
| PidFile "/var/run/httpd.pid"
| |
|
| |
| #LockFile "logs/httpd/accept.lock"
| |
| ↓
| |
| LockFile "/var/lock/subsys/httpd"
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="bash">
| |
| [root@XXXXX ~]# vi /usr/local/apache2/conf/httpd.conf
| |
| </syntaxhighlight>
| |
| <syntaxhighlight lang="vim">
| |
| # Server-pool management (MPM specific)
| |
| #Include conf/extra/httpd-mpm.conf
| |
| ↓
| |
| Include conf/extra/httpd-mpm.conf ← コメント外す
| |
| </syntaxhighlight>
| |
| httpd起動スクリプトの修正は同じ。
| |