Linux和Solaris建Apache虚拟根环境二(2)
来源:asp之家 时间:2010-05-08 18:04:00
5.7 为mysql的所有者编辑PATH变量,并且设定数据库的root密码。
$ [ Edit shell
login script .bash_profile: ]
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
$ . ~/.bash_profile ## source it!
$ mysqladmin -u root password '2mUch!data' ## pick your own password!
6.编译和安装PHP
6.1 先停止Apache后台程序(daemon)的运行
ROOT#chroot /www /apache/bin/apachectl stop
6.2 你首先要编译PHP
如果你使用的是non-DSO安装,你必须重新编译Apache。(每次要升级non-DSO包中的任何一个软件时,你都要再这样做一遍。)
$ cd /usr/local/src/chr ## I am NOT root!
$ tar zxf /path/to/php-4.02.tar.gz
$ cd php-4.02
non-DSO:
$ ./configure --with-mysql=/usr/local/mysql
--with-apache=../apache_1.3.12 --enable-track-vars
--with-config-file-path=/apache/conf --sharedstatedir=/tmp
DSO:
$ ./configure --with-mysql=/usr/local/mysql
--with-apxs=/apache/bin/apxs --enable-track-vars
--with-config-file-path=/apache/conf --sharedstatedir=/tmp
DSO:
(or add CFLAGS switch when mod_ssl was also configured as a DSO module)
$ CFLAGS=-DEAPI ./configure --with-mysql=/usr/local/mysql
--with-apxs=/apache/bin/apxs --enable-track-vars
--with-config-file-path=/apache/conf --sharedstatedir=/tmp
$ make
non-DSO:
$ make install
DSO:
ROOT# make install
进行DSO的PHP安装“make install”时,你必须是root。因为模块是直接进入模块目录树/apache/libexec的,另外,Apache的配置文件也改变了。
6.3 现在只讨论non-DSO安装,先重新编译Apache,再激活PHP模块
$ cd ../apache_1.3.12/
$ ./configure --with-layout=chroot
--enable-module=most --enable-module=so
--activate-module=src/modules/php4/libphp4.a
$ make
ROOT# make install ## I am root!
6.4 在实现了虚拟根环境目录树中,对PHP需要更多的共享库,可以用ldd来查看
For non-DSO: ldd /apache/bin/httpd
For DSO: ldd /apache/apache/libexec/libphp4.so
可以使用小的for循环,从/lib和/usr/lib中拷贝所需的文件
ROOT# cd /www
ROOT# for i in libresolv.so.2 libnsl.so.1 libpam.so.0 ; do
> cp -pi /lib/$i /www/lib/ ; done
ROOT# for i in libgd.so.
1 libgdbm.so.2 libz.so.1; do
> cp -pi /usr/lib/$i /www/usr/lib/ ; done