Tuesday, May 23, 2006

自宅サーバ環境構築ログ

[mysql]
Version:5.0.21

ユーザmysqlを追加
# /usr/sbin/groupadd mysql
# /usr/sbin/useradd -g mysql mysql

MySQLファイル解凍

# tar zxfv mysql-5.0.11.tar.gz

MySQLコンパイル,インストール

# cd mysql-5.0.11
# ./configure --prefix=/usr/local/mysql --with-extra-charsets=all --with-charset=ujis --with-mysqld-user=mysql
# make
# make install

# cp support-files/my-medium.cnf /etc/my.cnf
# cd /usr/local/mysql

# chown mysql /usr/local/mysql/var

MySQL初期設定

# /usr/local/mysql/bin/mysql_install_db --user=mysql
# chown -R root /usr/local/mysql
# chown -R mysql /usr/local/mysql/var
# chgrp -R mysql /usr/local/mysql

MySQLサーバ起動

# /usr/local/bin/mysqld_safe --user=mysql &


[apache]
Version:2.0.58

Apacheの解凍

# tar zxvf httpd-2.0.58.tar.gz

Apacheのコンパイル,インストール[DSO有効にてコンパイル]

# cd apache 1.3.14
# ./configure --enable-so --enable-mods-shared=all --enable-modules=most
# make
# make install

Apacheの起動

# /usr/local/apache/bin/apachectl start

※トラブルシューティング
・起動時に以下のエラーメッセージが出て起動できない
apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName [ !! ]

 → httpd.conf の ServerName の設定を 127.0.0.1:80 に設定して解消。

・起動時、エラーログに以下のエラーが出て起動できない
[alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "localhost.localdomain"

 → ホスト名と /etc/hosts に記述されてるホストがマッチしない場合に発生するらしい。
 → # hostname で表示したホスト名が /etc/hosts にない場合は追加することで解消する。


[libxml2]
Version:2-2.6.20
PHP のインストールに必要なライブラリのためインストール

# tar xvzf libxml2-2.6.20.tar.gz
# cd libxml2-2.6.20
# ./configure
# make
# make install


[libjpeg]
Version:6b
PHP のインストールに必要なライブラリのためインストール

# tar xvzf jpegsrc.v6b.tar.gz
# cd jpeg-6b
# ./configure --enable-shared
# make
# make install


[zlib]
Version:1.2.3
PHP のインストールに必要なライブラリのためインストール

# tar xvzf zlib-1.2.3.tar.gz
# cd jpeg-6b
# ./configure
# make
# make install


[libpng]
Version:1.2.10
PHP のインストールに必要なライブラリのためインストール

# tar xvzf libpng-1.2.10.tar.gz
# cd libpng-1.2.10
# cp scripts/makefile.linux makefile
$ vi makefile

------------------------------------
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

以下のように書き換え

ZLIBLIB=/usr/local/lib (または /usr/lib)
ZLIBINC=/usr/local/include (または /usr/include)
#ZLIBLIB=../zlib
#ZLIBINC=../zlib
------------------------------------

# ./configure
# make
# make install


[FreeType]
Version:2.1.10
PHP のインストールに必要なライブラリのためインストール

# tar xvzf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure
# make
# make install


[PHP]
Version:5.1.4

# tar xvzf php-5.1.4.tar.gz
# cd php-5.1.4
# ./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring --enable-mbregex --enable-zend-multibyte --enable-mbstr-enc-trans --with-zlib --with-gd --enable-gd-native-ttf --with-freetype-dir=/usr --with-png-dir=/usr --with-zlib --with-jpeg-dir=/usr --enable-exif --enable-ftp --with-pgsql --with-pear --with-mysql=/usr/local/mysql
# make
# make install

httpd.conf に以下の行を編集・追加

DirectoryIndex index.html index.html.var index.php
AddType application/x-httpd-php .php

※トラブルシューティング
以下のエラーが出て Apache が起動できない。

# /usr/local/apache2/bin/apachectl start
Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf:
Cannot load /usr/local/apache2/modules/libphp5.so into server:
/usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc:

以下のコマンドを実行することで解消。

# cd /usr/local/apache2/modules/
# chcon libphp5.so -t shlib_t

どうやら OS のセキュリティレベルとかち合うとかそんな理由らしい。

No comments: