Centos下Yum安装apache + PHP 以及升级
实验环境:
OS:Centos 5.5
内存:1024 MB
PHP: php 2.1
Apache:apache 2.2.3
第一步:
通过HTTP方式安装系统,安装系统比较简单,详细步骤省略。
第二步:
Yum安装Apache和PHP
1.准备编译环境(定制源码安装时所需要的开发环境)
yum install gcc gcc-c++ make automake autoconf
yum install qt4-sqlite qt4-mysql qt4-devel qt qt-devel
2.安装apache以及PHP相应WEB&库模块
yum install httpd hp-mcrypt php-mhash php-mbstring php-xml php-gd
yum install postgresql-devel httpd-devel openssl-devel libxml2-devel zlib-devel curl-devel libmcrypt-devel mhash-devel libjpeg-devel libpng-devel gd-devel freetype-devel libtool-ltdl-devel
3.查看系统安装版本
[root@bogon php-5.3.2]# httpd -v
Server version: Apache/2.2.3
Server built: Apr 4 2010 17:19:54
[root@bogon ~]# php -v
PHP 5.1.2.2 (cli) (built: May 27 2010 19:00:28)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
4.下载php-5.3.2源码到/usr/local并解压缩
[root@bogon local]# cd php
php-5.3.2.tar.bz2
[root@bogon local]# tar jxvf php-5.3.2.tar.bz2
5.编译安装PHP-5.3.2
[root@bogon local]./configure \
--prefix=/opt/php-5.3.2 \ (目录要提前建立)
--with-config-file-path=/opt/php-5.3.2/etc \(目录要提前建立)
--with-apxs2=/usr/sbin/apxs \ (需要安装httpd-devel,查询方法rpm -ql httpd-devel|moere)
[root@bogon local]Make && make install
[root@bogon local]cp /etc/php.ini /opt/php-5.3.2/etc
6.修改原来php.conf调用模块位置
[root@bogon local]cd /etc/httpd/conf.d/
[root@bogon conf.d]#vi php.conf
将里面内容
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>的文件libphp5.so替换成,(需要安装后的/opt/php-5.3.2/下的 libphp5.so,替换前要将/etc/httpd/modules/下的原libphp5.so 进行备份。)
7.重新启动服务,使修改生效。
[root@bogon local]service httpd restart
若出现类似错误,先禁用防火墙[root@bogon httpd]# service httpd restart
停止 httpd: [确定]
启动 httpd:httpd: Syntax error on line 210 of /etc/httpd/conf/httpd.conf: Syntax error on line 6 of /etc/httpd/conf.d/php.conf: Cannot load /etc/httpd/modules/libphp5.so into server: /etc/httpd/modules/libphp5.so: cannot open shared object file: No such file or directory
[失败]
8..删除原来的PHP-5.12版本
[root@bogon conf.d]#yum remove php\*
命令积累:yum search name ,需找与某个文件有关的东西。