1.查看老的php及apache
[root@localhost httpd]# rpm -q php
php-4.3.9-3.22.4
[root@localhost httpd]# rpm -q httpd
httpd-2.0.52-32.ent
2.卸载老的php及apache
rpm -e php --nodeps
rpm -e httpd --nodeps
3.安装新的apache
(1)下载httpd-2.2.9.tar 并解压
(2)cd httpd-2.2.9
(3) ./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-mpm=worker
遇见错误
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
zlib-devel 没装的原因
(1)安装zlib,libpng,freetype,libjpeg,gd
(2)安装openssl
scp -P 22 apalib.zip
[email protected]:/root/tools
scp -P 22 phplib.zip
[email protected]:/root/tools
scp -P 22 krb5-devel-1.3.4-47.x86_64.rpm
[email protected]:/root/tools
scp -P 22 e2fsprogs-devel-1.35-12.5.el4.x86_64.rpm
[email protected]:/root/tools
(4)再次cd /root/tools/httpd/httpd-2.2.9
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --enable-cgi --enable-rewrite --enable-deflate --with-mpm=worker
配置成功
(5)make
出现错误 cannot find the library `/usr/lib64/libexpat.la'
安装 expat-1.95.7
scp -P 22 expat-1.95.7-4.x86_64.rpm
[email protected]:/root/tools
scp -P 22 expat-devel-1.95.7-4.x86_64.rpm
[email protected]:/root/tools
再次
make clean
make
编译成功
(6)make install
安装成功
shell> /usr/local/apache2/bin/httpd -k start
shell> ps -ef
root 21294 1 0 18:23 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 21295 21294 0 18:23 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 21296 21294 0 18:23 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 21298 21294 0 18:23 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
daemon 21300 21294 0 18:23 ? 00:00:00 /usr/local/apache2/bin/httpd -k start
4.安装php
(1)解压 php-5.2.6.tar.gz 到
(2)cd php-5.2.6
(3)./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-zlib --with-libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-sockets --with-iconv --enable-mbstring --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
出现错误:configure: error: xml2-config not found. Please check your libxml2 installation.
发现差下面两个rpm
scp -P 22 libxml2-2.6.16-10.x86_64.rpm
[email protected]:/root/tools
scp -P 22 libxml2-devel-2.6.16-10.x86_64.rpm
[email protected]:/root/tools
(4)再次
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd --with-zlib --with-libpng --with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --enable-sockets --with-iconv --enable-mbstring --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
出现错误
configure: error: Unable to find gd.h anywhere under /usr/local/gd
发现gd.h在/usr/include下,修改为
./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd --with-zlib --with-libpng --with-jpeg --with-freetype --enable-sockets --with-iconv --enable-mbstring --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/usr/local/php5/etc
报错
configure: error: libjpeg.(a|so) not found.
修改如下
./configure --prefix=/usr/local/php --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-ttf --disable-json --enable-mbstring --with-mysql=/usr/local/mysql --with-mysql-sock --with-apxs2=/usr/local/apache2/bin/apxs
报错
configure: error: libjpeg.(a|so) not found.
[root@localhost php-5.2.6]# rpm --import /usr/share/rhn/RPM-GPG-KEY
[root@localhost php-5.2.6]# up2date libjpeg
按ok确认
下载jpegsrc.v6b.tar.gz
scp -P 22 jpegsrc.v6b.tar.gz
[email protected]:/root/tools
./configure --prefix=/usr/local/jpeg --enable-shared
mkdir -p /usr/local/jpeg/include
mkdir -p /usr/local/jpeg/lib
mkdir -p /usr/local/jpeg/bin
mkdir -p /usr/local/jpeg/man/man1
make && make install
失败
scp -P 22 gd-progs-2.0.28-5.4E.x86_64.rpm
[email protected]:/root/tools
失败
scp -P 22 configure2
[email protected]:/root/tools
//////////////////////////////
在configure中下列两处加echo,输出libjpeg.a libjpeg.so的查找路径
if test "$PHP_JPEG_DIR" != "no"; then
for i in $PHP_JPEG_DIR /usr/local /usr; do
echo $i/$PHP_LIBDIR/libjpeg.$SHLIB_SUFFIX_NAME;
test -f $i/$PHP_LIBDIR/libjpeg.$SHLIB_SUFFIX_NAME || test -f $i/$PHP_LIBDIR/libjpeg.a && GD_JPEG_DIR=$i && break
done
if test -z "$GD_JPEG_DIR"; then
{ echo "configure: error: libjpeg.(a|so) not found." 1>&2; exit 1; }
fi
// echo $i/$PHP_LIBDIR/libjpeg.$SHLIB_SUFFIX_NAME;是我们加的,当 --with-jpeg-dir=/usr/local/jpeg 输出为
/usr/local/lib
/usr/lib
/usr/local/jpeg/lib
于是如下处理:
cp /usr/lib64/libjpeg.* /usr/local/jpeg/lib
./configure --prefix=/usr/local/php --with-gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir --with-zlib-dir --with-ttf --disable-json --enable-mbstring --with-mysql=/usr/local/mysql --with-mysql-sock --with-apxs2=/usr/local/apache2/bin/apxs
configure: error: libpng.(a|so) not found.
mkdir /usr/local/png
mkdir /usr/local/png/lib
mkdir /usr/local/png/include
cp /usr/include/libpng12/* /usr/local/png/include
cp /usr/include/pnglib/* /usr/local/png/lib/
./configure --prefix=/usr/local/php --with-gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-zlib-dir --with-ttf --disable-json --enable-mbstring --with-mysql=/usr/local/mysql --with-mysql-sock --with-apxs2=/usr/local/apache2/bin/apxs
配置成功
make
成功
make install
成功
5.整合apache 和php
cp php.ini-dist /usr/local/php/etc/php.ini
vi /usr/local/php/etc/php.ini
将extension=php_mysql.dll前面的#去掉
vi /usr/local/apache2/conf/httpd.conf
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .inc
/usr/local/apache2/bin/apachectl restart
到此 mysql+apache+php 安装完毕
测试apache
shell> wget http://127.0.0.1/
测试php
shell> cd htdosc
shell> vi index.php
<?php
phpinfo();
?>
[root@localhost htdocs]# wget http://127.0.0.1/index.php
--23:57:46-- http://127.0.0.1/index.php
=> `index.php.1'
Connecting to 127.0.0.1:80... 宸茶繛鎺ャ€?
宸插彂鍑?HTTP 璇锋眰锛屾鍦ㄧ瓑寰呭洖搴?.. 200 OK
闀垮害锛氭湭鎸囧畾 [text/html]
[ <=> ] 44,565 --.--K/s
23:57:46 (39.91 MB/s) - `index.php.1' saved [44565]
[root@localhost htdocs]# cat index.php.1
结果正确!
6.综观:
(1)mysql
安装位置:/usr/local/mysql
启动: /etc/init.d/mysql start
配置文件:/etc/my.cnf
(2)apache2
安装位置:/usr/local/apache2
启动: /usr/local/apache2/bin/apachectl restart
配置文件: /usr/local/apache2/conf/httpd.conf
(3)php
配置文件:/usr/local/php/etc/php.ini