purazumakoiの[はてなブログ]

技術メモから最近はライフログも増えてきてます。

CloudCore VPS CV01を使ってみた その3 suPHPでphp4.4、5.2、5.3を同居させる の続き1

CloudCore VPS CV01を使ってみた その3 suPHPでphp4.4、5.2、5.3を同居させる - purazumakoiの[はてなブログ]
の続き1

続き1です

MySQL4.0.27のインストール

PHP4はMySQL4に繋ぐ想定ということでここもソースからコンパイル、ビルドして入れる。

GCCが3.4じゃないとコンパイル出来ないみたいなので入れる
# yum -y install compat-gcc-34 compat-gcc-34-c++
# yum -y install ncurses-devel

via
守破離でいこう!!: MySQL 3.23.58 を CentOS 5.2 にインストールする

# cd /root/
# wget http://mirror.provenscaling.com/mysql/community/source/4.0/mysql-4.0.27.tar.gz
# tar xvf mysql-4.0.27.tar.gz
# cd /root/mysql-4.0.27

# vi mysys/my_thr_init.c
変更箇所(「/my_fast_mutexattr」← viの検索コマンドで検索したら見つかる)
↓----------------------------------
#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_t my_fast_mutexattr;
#endif

↓このようにコメントアウト↓

//#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
pthread_mutexattr_t my_fast_mutexattr;
//#endif
------------------------------------↑

↓以下一気にコピペ(mysql4は3307ポートにする)

CC=/usr/bin/gcc34 CXX=/usr/bin/g++34 \
./configure \
--prefix=/usr/local/mysql \
--with-charset=ujis \
--with-extra-charsets=all \
--with-mysqld-usr=mysql \
--with-innodb \
--enable-local-infile \
--with-unix-socket-path=/tmp/mysql.sock \
--with-tcp-port=3307 \
--with-named-thread-libs="-lpthread"

# make
# make install

最後のへんに
----------------
test -z "/usr/local/mysql/share/mysql" || mkdir -p -- "/usr/local/mysql/share/mysql"
 /usr/bin/install -c 'mysql.server' '/usr/local/mysql/share/mysql/mysql.server'
make[3]: ディレクトリ `/root/mysql-4.0.27/support-files' から出ます
make[2]: ディレクトリ `/root/mysql-4.0.27/support-files' から出ます
make[1]: ディレクトリ `/root/mysql-4.0.27/support-files' から出ます
----------------
って出てるからOKかしら


# /usr/local/mysql/bin/mysql_install_db --datadir=/usr/local/mysql/var --basedir=/usr/local/mysql --user=mysql

# vi /etc/my4.cnf
--- 新規入力 -------------
[client]
port     = 3307
socket   = /tmp/mysql.sock
[mysqld]
pid-file = /usr/local/mysql/mysqld4.pid
datadir  = /usr/local/mysql/var
port     = 3307
socket   = /tmp/mysql.sock
[mysqld_safe]
log-error=/var/log/mysqld4.log
pid-file=/usr/local/mysql/mysqld4.pid
--------------


# chown -R mysql:mysql /usr/local/mysql
# cd /usr/local/mysql/share/mysql/
# cp mysql.server /etc/rc.d/init.d/mysql.server

起動スクリプトを修正して「/etc/my4.cnf」を見るようにする
# vi /etc/rc.d/init.d/mysql.server

my4.cnfとかぶるのはどうもこっちのが優先される?
basedir=/usr/local/mysql
datadir=/usr/local/mysql/var
pid_file=/usr/local/mysql/mysqld4.pid

---- 155行目辺りに「--defaults-file=/etc/my4.cnf」を追記
$bindir/mysqld_safe --defaults-file=/etc/my4.cnf --datadir=$datadir --pid-file=$pid_file >/dev/null 2>&1 &

via
http://www.softel.co.jp/blogs/tech/archives/1070


# vi /usr/local/mysql/share/mysql/charsets/Index
#--------
cp1251 14

cp1251 83
#--------------

起動
# /etc/rc.d/init.d/mysql.server start
起動確認
# /etc/rc.d/init.d/mysql.server restart
うまく行かなかった場合
cat /var/log/mysqld4.log   # ログを見る
ps -ef | grep mysql        # プロセスを見る
netstat -nlp               # ポートを見る



# chkconfig mysql.server on
# chkconfig --list mysql.server

パスワード設定(ソケットじゃなく TCP/IP指定の場合はIP、ポート指定でいく)
# /usr/local/mysql/bin/mysqladmin -h 127.0.0.1 -P 3307 -u root password password01
# /usr/local/mysql/bin/mysql  -h 127.0.0.1 -P 3307 -u root -p

#!==================================================
use mysql
delete from user where Password="";
flush privileges;
grant ALL on *.* to purazumakoi identified by 'password01';
update user set Host="124.xxx.xxx.xxx" where User="purazumakoi"; #ユーザのホスト
flush privileges;
quit
#!==================================================

perl-DBD-MySQLを入れる
# yum -y install perl-ExtUtils-MakeMaker
# cd /root/
# wget http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.018.tar.gz
# tar zxvf DBD-mysql-4.018.tar.gz
# cd /root/DBD-mysql-4.018
# perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config

# make
# make install

# vi /etc/ld.so.conf.d/mysql.conf

↓-新規作成----------------------------
/usr/local/mysql/lib/mysql/
---------------------------------------↑
# ldconfig

このへんの奮闘記は
CentOS6にMySQL4.0.27を入れようとしたがmakeでエラーが出た。 - purazumakoiの[はてなブログ]

PHP4.4.9のインストール

とりあえず、openssl1.0.0以上だと古いPHPをソールからビルドする場合色々困ることがあるみたい

openssl1.0.0でPHP4.4.9を入れるためのopenssl.c

保存用として
https://dl.dropboxusercontent.com/u/21100684/openssl.chttp://purazumakoi.info/openssl/openssl.c
に置いておきました。


# cd /root/
# tar zxvf php-4.4.9.tar.gz
# cd php-4.4.9

# yum -y install httpd-devel
# yum -y install gd gd-devel libjpeg-devel libpng-devel
シンボリックリンクはっておかないとライブライがないっていわれるので
# ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
# ln -s /usr/lib64/libpng.so /usr/lib/libpng.so


openssl.c を一時的に差し替える
# cd ./ext/openssl/
とりあえず基あったのをバックアップですね。
# mv openssl.c openssl.c.bk
openssl.c の内容をコピペ
# vi openssl.c


# cd /root/php-4.4.9

↓以下一気にコピペ
./configure \
--prefix=/usr/local \
--program-suffix=-4.4.9 \
--with-config-file-path=/usr/local/etc/php_conf_4.4.9 \
--with-system-regex \
--disable-debug \
--enable-track-vars \
--with-gd \
--with-libdir=lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-png \
--with-png-dir=/usr/lib64 \
--with-zlib  \
--with-mysql=/usr/local/mysql \
--with-pgsql=/usr/local/pgsql7 \
--with-openssl \
--enable-versioning \
--enable-mbstring \
--enable-mbregex \
--enable-zend-multibyte \
--enable-jstring \
--enable-trans-sid \
--enable-discard-path \
--without-pear

# make
# make install

php.iniを置く場所を作る
# mkdir /usr/local/etc/php_conf_4.4.9
# cp php.ini-recommended /usr/local/etc/php_conf_4.4.9/php.ini


次はsuPHPでPHPのモードを選べるようにしよう!
CloudCore VPS CV01を使ってみた その3 suPHPでphp4.4、5.2、5.3を同居させる の続き2 PHP切り替え - purazumakoiの[はてなブログ]