<b>CentOS 5.5上编译安装 PHP 5.3.6</b>[服务器安全]
本文“<b>CentOS 5.5上编译安装 PHP 5.3.6</b>[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
CentOS 5.6一向没公布,CentOS 5.5的PHP5.1.6不支持json/hash,因为正研究Postfix+Dovecot邮件系统,webmail采取的 RoundCube 新版本(v0.5)要求PHP版本不小于5.2.1,于是决意编译安装最新版PHP.PHP前几天被入侵据说v5.3.6代码被污染,不过用来做研究测试 应当没问题.
先卸载本机已经安装的PHP包,这些软件包将会通过接下来的编译方法安装,安装必须软件
# yum remove php php-common php-devel php-cli php-mbstring php-mhash \
php-mysql php-pgsql php-ldap php-imap php-pear php-pdo php-gd
假如不需求pgsql数据库则可以去掉postgresql相关包
# yum install httpd-devel libtool-ltdl libtool-ltdl-devel openssl-devel \
libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \
libc-client libc-client-devel gd gd-devel libmcrypt libmcrypt-devel \
sqlite sqlite-devel mysql-devel libicu libicu-devel pcre-devel \
postgresql84 postgresql84-libs postgresql84-server postgresql84-devel \
假如不安装 libtool-ltdl-devel编译时会出错,所以要末安装这个包要末履行以下号令:
# cd /usr/lib
# ln -s libltdl.so.3.1.4 libltdl.so
libicu是 --enable-intl Enable internationalization support 需求的包下载源代码到 src 目录并解压:
# cd /usr/local/src
# wget http://cn.php.net/get/php-5.3.6.tar.bz2/from/this/mirror
# tar -xjf php-5.3.6.tar.bz2
配置安装参数
./configure --build=i686-RedHat-linux-gnu --host=i686-redhat-linux-gnu \
--target=i686-RedHat-linux-gnu --with-apxs2=/usr/sbin/apxs \
--prefix=/usr/local --exec-prefix=/usr/local --with-exec-dir=/usr/local/bin \
--sysconfdir=/etc --libdir=/usr/local/lib/php --with-libdir=lib \
--sbindir=/usr/local/sbin --sharedstatedir=/usr/com --datadir=/usr/local/share \
--includedir=/usr/local/include --libexecdir=/usr/local/libexec \
--localstatedir=/var --cache-file=../config.cache \
--mandir=/usr/local/share/man --infodir=/usr/local/share/info \
--with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d \
--with-pic --with-curl=shared --with-freetype-dir --with-png-dir \
--with-gettext --with-gmp --with-iconv --with-jpeg-dir --with-png-dir \
--with-openssl --with-layout=GNU --with-libxml-dir \
--with-pcre-regex=/usr \
--with-mcrypt=shared --with-mhash --with-zlib --with-bz2=shared \
--with-pdo-mysql --with-mysql --with-mysql-sock=/var/lib/mysql/mysql.sock \
--with-pgsql --with-pdo-pgsql --with-sqlite=shared --with-pdo-sqlite=shared \
--enable-sqlite-utf8 --with-kerberos --with-imap --with-imap-ssl \
--with-pear --with-gd --enable-gd-native-ttf --enable-calendar=shared \
--enable-exif --enable-ftp --enable-sockets --enable-bcmath \
--enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-intl \
--enable-mbstring --enable-zend-multibyte --enable-zip \
--without-unixODBC --disable-tokenizer \
非RHEL/CentOS系统可以省略 --build,--host,--target 参数,程序会自动判断(LINUX普通为i686-pc-linux-gnu).假如没安装pgsql大概不需求pgsql的支持可以删除相关参数(共2 个). bz2, calendar, curl, mcrypt, pdo_sqlite, sqlite 这些模块采取动态编译,可采取下面将会提到的办法加载.编译并安装
# make && make install
安装后果择要,里面有几个主要的安装途径变量
libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-5.3.6/libs'
[activating module `php5' in /etc/httpd/conf/httpd.conf]
Installing PHP CLI binary: /usr/local/bin/
Installing PHP CLI man page: /usr/local/share/man/man1/
Installing shared extensions: /usr/local/lib/php/20090626/
Installing build environment: /usr/local/lib/php/build/
Installing header files: /usr/local/include/php/
Installing helper programs: /usr/local/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/share/man/man1/
Installing PEAR environment: /usr/local/share/pear/
貌似要运行一次libtool --finish ....,不过我运行后也没什么独特效果~
更新httpd配置文件以便apache能解析php文件
# vim /etc/httpd/conf/httpd.conf
增添以下内容
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
假如在卸载原有PHP之前没备份php.ini文件,那么可以从PHP编译目录中把 php.ini-production 拷贝到 /etc目录下并改名为 php.ini
# mv /usr/local/src/php-5.3.6/php.ini-production /etc/php.ini
增添大概更新相关设置,比方:
extension_dir = "/usr/local/lib/php/20090626"
# 以下六个模块可按照需求增添
extension = bz2.so
extension = calendar.so
extension = curl.so
extension = mcrypt.so
extension = pdo_sqlite.so
extension = sqlite.so
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
variables_order = "EGPCS"
register_globals = Off
register_long_arrays = Off
post_max_size = 30M
upload_max_filesize = 30M
mbstring.internal_encoding = UTF-8
date.timezone = Asia/Chongqing
测试后果.在 /var/www/html 下面新建一个文件 phpinfo.php ,里面包含内容
Php代码
<?php
phpinfo();
?>
重启apache服务
# service httpd restart
然后在浏览器翻开 http://192.168.0.1/phpinfo.php 文件查看php配置情况,这里ip地址为服务器地址
以上是“<b>CentOS 5.5上编译安装 PHP 5.3.6</b>[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |