アットウィキロゴ
bobobo_bo @Wiki
掲示板 掲示板 ページ検索 ページ検索 メニュー メニュー

bobobo_bo @Wiki

LAMP

最終更新:

匿名ユーザー

- view
だれでも歓迎! 編集

Apache+PHP+MySQL+Postgres


構築環境

CentOS (4.3)
Apache (1.3.36)
PHP (4.4.2)
MySQL (4.1.20)
Postgres (8.1.4)

OpenSSL (0.9.8b)

$ tar -zxvf openssl-0.9.8b.tar.gz
$ cd openssl-0.9.8b/
$ ./config \
--prefix=/usr/local \
--openssldir=/usr/local/openssl \
-fPIC
$ make
$ make test
$ su
# make install

Apache(1.3.36) + mod_ssl(1.3.36)

$ tar -zxvf apache_1.3.36.tar.gz
$ tar -zxvf mod_ssl-2.8.27-1.3.36.tar.gz
$ cd mod_ssl-2.8.27-1.3.36/
$ ./configure \
--with-apache=../apache_1.3.36 \
--with-ssl=../openssl-0.9.8b \
--prefix=/usr/local/apache \
--enable-shared=ssl \
--enable-module=so

Apache (1.3.36)

$ cd apache_1.3.36/
$ make
$ make certificate
$ su
# make install
SSL Key の作成 Signature Algorithm ((R)SA or (D)SA) [R]:R
 → 認証方式は: RSA

1. Country Name (2 letter code) [XY]:JP
 → 国名は: JAPAN

2. State or Province Name (full name) [Snake Desert]:Tokyo
 → 都道府県は:Tokyo

3. Locality Name (eg, city) [Snake Town]:Minato
 → 市区町村は:Minato

4. Organization Name (eg, company) [Snake Oil, Ltd]:XXXX
 → 団体名、企業名は:XXXX

5. Organizational Unit Name (eg, section) [Webserver Team]:XXXX
 → 所属部署は:XXXX

6. Common Name (eg, FQDN) [www.snakeoil.dom]:XXXX
 → 組織名は:XXXX

7. Email Address (eg, name@FQDN) [[email protected]]:[email protected]
 → メールアドレスは:[email protected]

8. Certificate Validity (days) [365]:90
 → 証明書の有効期限は:90

Certificate Version (1 or 3) [3]:3
 → 証明書のバージョンは:3

Encrypt the private key now? [Y/n]:Y
 → 証明書の暗号化を行うか:Y

Enter PEM pass phrase: ????
 → パスワード入力:????

Verifying password - Enter PEM pass phrase:????
 → パスワード再入力:????

  • httpd.confを編集
ServerName www.xxx.com

Postgres

$ su -
# useradd postgres
# mkdir /usr/local/pgsql
# chown postgres:postgres /usr/local/pgsql/
# su postgres
$ tar -zxvf postgresql-8.1.4.tar.gz
$ cd postgresql-8.1.4/
$ ./configure --enable-multibyte=EUC_JP
$ make all
$ make install

PostgreSQL の実行まで

postgres ユーザーの .bash_profile へ操作設定の記述をします。
PATH=$PATH:$HOME/bin:/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGDATA=/home/postgres/data
export PGLIB=/usr/local/pgsql/lib
export LD_LIBRARY_PATH=/usr/local/pgsql/lib
その後にプロファイルをロードし、Postgres 環境の初期化と Postmaster の起動を行います。
$ . .bash_profile ($ source .bash_profile)
$ initdb
$ pg_ctl start -l [LogFileName] -s -D  /home/postgres/data/ -o -i

これで環境は整いました。
createuser createdb を行い、psql で操作を行います。

MySQL

$ su -
# useradd mysql
# su mysql
$ tar xvzf   ./mysql-4.1.20.tar.gz
$ cd mysql-4.1.20
$ ./configure \
--prefix=/usr/local/mysql \
--with-charset=ujis \
--with-extra-charsets=all \
--with-mysqld-user=mysql \
--without-bench \
--localstatedir=/home/mysql/data
$ make
$ su
# make install

MySQL の実行まで mysql ユーザーの .bash_profile へ操作設定の記述をします。

  PATH=$PATH:/usr/local/mysql/bin
  export MANPATH=$MANPATH:/usr/local/mysql/man

その後にプロファイルをロードし、MySQL 環境の初期化と MySQL の起動を行います。

  $ . .bash_profile ($ source .bash_profile)
  $ /usr/local/mysql/bin/mysql_install_db --user=mysql
  $ /usr/local/mysql/bin/mysqld_safe --user=mysql &

自動起動させるために /etc/rc.d/rc.local へ以下の記述を行います。

  /usr/local/mysql/bin/safe_mysqld --user=mysql &

これで環境は整いました。


PHP4

$ tar -zxvf php-4.2.2.tar.gz
$ cd php-4.2.2/
$ ./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--with-pgsql=/usr/local/pgsql \
--with-mysql=/usr/local/mysql \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-gd-native-ttf \
--with-gd \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--with-zlib=/usr \
--with-png-dir=/usr
$ make
$ su
# make install

PHPの設定ファイルをコピーします。

#cp
php.ini-dist /usr/local/lib/php.ini

次にApacheでPHPを使用する設定をします。/use/local/apache/conf/httpd.confを開き編集します。

#vi
/use/local/apache/conf/httpd.conf

                                • 省略----------------

#
# Example:
# LoadModule foo_module libexec/mod_foo.so
LoadModule php4_module libexec/libphp4.so  ←LoadModuleの最後に追記する。

# Reconstruction of the complete module list from all available modules
# (static and shared ones) to achieve correct module execution order.
# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]
AddModule mod_php4.c  ←AddModuleの最後に追記する。

                                • 省略----------------

#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
   DirectoryIndex index.html index.php  ←index.phpを追記する。
</IfModule>

                                • 省略----------------

#
# PHP
#
AddType application/x-httpd-php .php .php4
AddType application/x-httpd-php-source .phps .php4s

httpd.confの編集が終了したらhttpd.confの構文チェックを行います。

#/usr/local/apache/bin/apachectl configtest
Syntax OK

Apacheを再起動して完了です。

#/usr/local/apache/bin/apachectl restart



参考サイト

最近更新されたスレッド
ウィキ募集バナー