通常配布されている Apache の RPM パッケージでは suEXEC のルートディレクトリが /var/www になっています。
/home ディレクトリ以下をドキュメントルートに使う場合は CGI が正常に動作しません。
この問題を解消するために RPM パッケージをカスタマイズします。
Apache ダウンロード
理研のダウンロードページから httpd-2.xxxx.ent.centos4.src.rpm を確認して下さい(xxxx の部分はバージョンです)FTP : ftp://ftp.riken.jp/Linux/centos/5.1/os/SRPMS/
HTTP: http://ftp.riken.jp/Linux/centos/5.1/os/SRPMS/
Apache ダウンロード
[root@linux ~]# cd /home/admin
[root@linux admin]# wget ftp://ftp.riken.jp/Linux/centos/5.1/os/SRPMS/httpd-*
--17:39:48-- ftp://ftp.riken.jp/Linux/centos/4/os/SRPMS/httpd-*
=> `httpd-2.0.52-28.ent.centos.src.rpm'
ftp.riken.jp をDNSに問いあわせています... 134.160.38.1
ftp.riken.jp|134.160.38.1|:21 に接続しています... 接続しました。
anonymous としてログインしています... ログインしました!
==> SYST ... 完了しました。 ==> PWD ... 完了しました。
==> TYPE I ... 完了しました。 ==> CWD /Linux/centos/4/os/SRPMS ... 完了しました。
==> PASV ... 完了しました。 ==> RETR httpd-2.0.52-28.ent.centos4.src.rpm ... 完了しました。
長さ: 7,058,212 (6.7M) (確証はありません)
100%[==================================================================>] 7,058,212 2.08M/s ETA 00:00
17:39:52 (2.07 MB/s) - `httpd-2.0.52-28.ent.centos4.src.rpm' を保存しました [7058212]
[root@linux admin]#
マルチスレッド対応させる場合(worker)
参考サイトhttp://www.atmarkit.co.jp/flinux/rensai/apache2_01/apache01b.html
再コンパイル環境の準備
作業ディレクトリ作成(存在しない場合)
[root@linux ~]# mkdir -p /usr/src/redhat/SOURCES
[root@linux ~]#
rpm 実行
途中で 警告 が出ることがありますが、問題ありません
[root@linux ~]# cd /home/admin
[root@linux admin]# rpm -ihv httpd-2.0.52-28.ent.centos4.src.rpm
1:httpd 警告: user buildcentos does not exist - using root
警告: group buildcentos does not exist - using root
~ 中略 ~
警告: group buildcentos does not exist - using root
########################################### [100%]
警告: user buildcentos does not exist - using root
~ 中略 ~
警告: group buildcentos does not exist - using root
[root@linux admin]#
SUEXECのドキュメントルートを変更する /usr/src/redhat/SPECS/httpd.spec の編集
[root@linux ~]# vi /usr/src/redhat/SPECS/httpd.spec
%define contentdir /var/www ←■ /home に変更する
%define suexec_caller apache
%define mmn 20051115
%define vstring CentOS
%define distro CentOS
Summary: Apache HTTP Server
Name: httpd
Version: 2.2.3
Release: 11%{dist} ←■ 11.e15.centos 等に変更する(その時のバージョンを確認の事)
URL: http://httpd.apache.org/
fml CGIなどのためにvpopmailユーザーでもホームページを公開できるようにしてます。
必要がなければ、デフォルトのままでも良いと思います
--with-suexec-uidmin=500 --with-suexec-gidmin=500 \
↓
--with-suexec-uidmin=89 --with-suexec-gidmin=89 \
再コンパイルに必要なパッケージインストール
[root@linux ~]# yum install rpm-build autoconf automake libtool
Setting up Install Process
Setting up repositories
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
~ 中略 ~
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
autoconf noarch 2.59-5 base 628 k
automake noarch 1.9.2-3 base 442 k
libtool i386 1.5.6-4.EL4.1.c4.4 base 635 k
rpm-build i386 4.3.3-18_nonptl base 456 k
Installing for dependencies:
libtool-libs i386 1.5.6-4.EL4.1.c4.4 base 23 k
Transaction Summary
=============================================================================
Install 5 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 2.1 M
Is this ok [y/N]: n
Exiting on user Command
Complete!
[root@linux ~]# yum -y install rpm-build autoconf automake libtool
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
~ 中略 ~
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
autoconf noarch 2.59-5 base 628 k
automake noarch 1.9.2-3 base 442 k
libtool i386 1.5.6-4.EL4.1.c4.4 base 635 k
rpm-build i386 4.3.3-18_nonptl base 456 k
Installing for dependencies:
libtool-libs i386 1.5.6-4.EL4.1.c4.4 base 23 k
Transaction Summary
=============================================================================
Install 5 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 2.1 M
Downloading Packages:
(1/5): rpm-build-4.3.3-18 100% |=========================| 456 kB 00:00
(2/5): autoconf-2.59-5.no 100% |=========================| 628 kB 00:00
(3/5): libtool-libs-1.5.6 100% |=========================| 23 kB 00:00
(4/5): automake-1.9.2-3.n 100% |=========================| 442 kB 00:00
(5/5): libtool-1.5.6-4.EL 100% |=========================| 635 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: autoconf ######################### [1/5]
Installing: automake ######################### [2/5]
Installing: libtool-libs ######################### [3/5]
Installing: rpm-build ######################### [4/5]
Installing: libtool ######################### [5/5]
Installed: autoconf.noarch 0:2.59-5 automake.noarch 0:1.9.2-3 libtool.i386 0:1.5.6-4.EL4.1.c4.4 rpm-build.i386 0:4.3.3-18_nonptl
Dependency Installed: libtool-libs.i386 0:1.5.6-4.EL4.1.c4.4
Complete!
[root@linux ~]#
依存ファイルを確認・表示
[root@linux ~]# rpmbuild --bb /usr/src/redhat/SPECS/httpd.spec
エラー: Failed build dependencies:
db4-devel is needed by httpd-2.0.52-28.ent.centos4.i386
expat-devel is needed by httpd-2.0.52-28.ent.centos4.i386
pkgconfig is needed by httpd-2.0.52-28.ent.centos4.i386
xmlto >= 0.0.11 is needed by httpd-2.0.52-28.ent.centos4.i386
apr-devel >= 0.9.4-24.2 is needed by httpd-2.0.52-28.ent.centos4.i386
apr-util-devel is needed by httpd-2.0.52-28.ent.centos4.i386
pcre-devel is needed by httpd-2.0.52-28.ent.centos4.i386
distcache-devel is needed by httpd-2.0.52-28.ent.centos4.i386
[root@linux ~]#
依存ファイルを確認でエラーが出たパッケージのインストール
[root@linux ~]# yum -y install db4-devel expat-devel pkgconfig xmlto apr-devel apr-util-devel pcre-devel distcache-devel
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
~ 中略 ~
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
apr-devel i386 0.9.4-24.5.c4.2 base 503 k
apr-util-devel i386 0.9.4-21 base 239 k
db4-devel i386 4.2.52-7.1 base 1.8 M
distcache-devel i386 1.4.5-6 base 75 k
expat-devel i386 1.95.7-4 base 118 k
pcre-devel i386 4.5-3.2.RHEL4 base 96 k
pkgconfig i386 1:0.15.0-3 base 47 k
xmlto i386 0.0.18-4 base 25 k
Installing for dependencies:
apr i386 0.9.4-24.5.c4.2 base 88 k
apr-util i386 0.9.4-21 base 51 k
cyrus-sasl-devel i386 2.1.19-5.EL4 base 1.3 M
dialog i386 1.0.20040731-3 base 138 k
distcache i386 1.4.5-6 base 111 k
docbook-dtds noarch 1.0-25 base 528 k
docbook-style-xsl noarch 1.65.1-2 base 1.4 M
netpbm i386 10.25-2.EL4.3 base 110 k
netpbm-progs i386 10.25-2.EL4.3 base 1.6 M
openjade i386 1.3.2-14 base 1.9 M
openldap-devel i386 2.2.13-6.4E base 1.3 M
passivetex noarch 1.25-3 base 74 k
psutils i386 1.17-23 base 83 k
sgml-common noarch 0.6.3-17 base 41 k
tetex i386 2.0.2-22.EL4.7 base 10 M
tetex-dvips i386 2.0.2-22.EL4.7 base 672 k
tetex-fonts i386 2.0.2-22.EL4.7 base 20 M
tetex-latex i386 2.0.2-22.EL4.7 base 4.9 M
xml-common noarch 0.6.3-17 base 5.8 k
xmltex noarch 20020625-3 base 41 k
Transaction Summary
=============================================================================
Install 28 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 47 M
Downloading Packages:
(1/28): xmlto-0.0.18-4.i3 100% |=========================| 25 kB 00:00
~ 中略 ~
(28/28): tetex-fonts-2.0. 100% |=========================| 20 MB 00:07
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: tetex-fonts ####################### [ 1/28]
~ 中略 ~
Installing: openjade ####################### [28/28]
Installed: apr-devel.i386 0:0.9.4-24.5.c4.2 apr-util-devel.i386 0:0.9.4-21
db4-devel.i386 0:4.2.52-7.1 distcache-devel.i386 0:1.4.5-6 expat-devel.i386 0:1.95.7-4
pcre-devel.i386 0:4.5-3.2.RHEL4 pkgconfig.i386 1:0.15.0-3 xmlto.i386 0:0.0.18-4
Dependency Installed: apr.i386 0:0.9.4-24.5.c4.2 apr-util.i386 0:0.9.4-21
cyrus-sasl-devel.i386 0:2.1.19-5.EL4 dialog.i386 0:1.0.20040731-3 distcache.i386 0:1.4.5-6
docbook-dtds.noarch 0:1.0-25 docbook-style-xsl.noarch 0:1.65.1-2 netpbm.i386 0:10.25-2.EL4.3
netpbm-progs.i386 0:10.25-2.EL4.3 openjade.i386 0:1.3.2-14 openldap-devel.i386 0:2.2.13-6.4E
passivetex.noarch 0:1.25-3 psutils.i386 0:1.17-23 sgml-common.noarch 0:0.6.3-17
tetex.i386 0:2.0.2-22.EL4.7 tetex-dvips.i386 0:2.0.2-22.EL4.7 tetex-fonts.i386 0:2.0.2-22.EL4.7
tetex-latex.i386 0:2.0.2-22.EL4.7 xml-common.noarch 0:0.6.3-17 xmltex.noarch 0:20020625-3
Complete!
[root@linux ~]#
RPM パッケージのビルドを行う
バイナリパッケージとソースパッケージのビルドを行い、RPM パッケージを作成します。
[root@linux ~]# rpmbuild --bb /usr/src/redhat/SPECS/httpd.spec
~ 中略 ~
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/httpd-root
書き込み中: /usr/src/redhat/RPMS/i386/httpd-2.0.52-28.ent.centos4.i386.rpm
書き込み中: /usr/src/redhat/RPMS/i386/httpd-devel-2.0.52-28.ent.centos4.i386.rpm
書き込み中: /usr/src/redhat/RPMS/i386/httpd-manual-2.0.52-28.ent.centos4.i386.rpm
書き込み中: /usr/src/redhat/RPMS/i386/mod_ssl-2.0.52-28.ent.centos4.i386.rpm
書き込み中: /usr/src/redhat/RPMS/i386/httpd-suexec-2.0.52-28.ent.centos4.i386.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.38298
+ umask 022
+ cd /usr/src/redhat/BUILD
+ cd httpd-2.0.52
+ rm -rf /var/tmp/httpd-root
+ exit 0
[root@linux ~]#
Apache インストール
[root@linux ~]# cd /usr/src/redhat/RPMS/i386
[root@linux i386]# rpm -ihv httpd-2.0.52-28.ent.centos4.i386.rpm httpd-devel-2.0.52-28.ent.centos4.i386.rpm
httpd-suexec-2.0.52-28.ent.centos4.i386.rpm mod_ssl-2.0.52-28.ent.centos4.i386.rpm
Preparing... ########################################### [100%]
1:httpd ########################################### [ 25%]
2:httpd-devel ########################################### [ 50%]
3:httpd-suexec ########################################### [ 75%]
4:mod_ssl ########################################### [100%]
[root@linux i386]#
Apache ドキュメントルート作成
apache のユーザ情報変更
[root@linux ~]# usermod -d /home/apache apache
/home/apache ディレクトリ作成
[root@linux ~]# mkdir -p /home/apache/public_html
/home 直下の apache ディレクトリを移動
[root@linux ~]# mv /home/cgi-bin /home/apache
[root@linux ~]# mv /home/error /home/apache
[root@linux ~]# mv /home/html /home/apache
[root@linux ~]# mv /home/icons /home/apache
[root@linux ~]# mv /home/manual /home/apache
所有者を apache にする
[root@linux ~]# chown -R apache:apache apache
[root@linux ~]#
Apache のパス → /usr/sbin/httpd
これで、Apache のインストールは終了です。
※ 続いて Apache 初期設定 → CentOS/Apache/httpd.conf 設定
0 件のコメント:
コメントを投稿