Centos源代码编译安装PHP

PHP的安装步骤,版本为5.3.X

1、 centos已经完成系统初始化,已经安装编译安装gcc、make等工具。

2、 下载PHP源码包,解压

3、 安装必要的支持包,否则生产环境下将会出现很多问题,不支持很多功能。

yum -y install libxml2  libxml2-devel

yum -y install libcurl  curl-devel

yum -y install libjpeg  libjpeg-devel

yum -y install libpng   libpng-devel

yum -y install freetype freetype-devel

yum -y install glibc    glibc-devel glib2 glib2-devel

yum -y install ncurses  openssl-devel

yum -y install libmcrypt libmcrypt-devel

yum -y install bzip2 

如果configure提示缺少去其它的安装依赖包,先检查系统中是否已经安装。如果没有,则使用yum或者源码编译安装。如libiconv也经常找不到库文件。

4、 配置

# ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=daemon --with-fpm-group=daemon--with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-iconv-dir  --with-freetype-dir  --with-jpeg-dir  --with-png-dir  --with-gd --with-zlib --with-libxml-dir --with-curl --with-curlwrappers  --with-mhash  --with-xmlrpc --with-mcrypt --with-openssl --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-gd-native-ttf --enable-ftp  --enable-pcntl  --enable-sockets  --enable-zip --enable-soap  --disable-debug  --disable-ipv6

注意安装检查是否有缺少软件包提示。

5、 编译安装

先用top命令检查cpu的核数,如果系统的核数为8

make选项可以为

#make -j 8

#make test

#make install

注意make是否产生错误,一些警告可以忽略

6、 设置开机启动

拷贝SystemV脚本

#cpphp.ini-production /usr/local/php/etc/php.ini

#cp sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

#chmod a+x/etc/init.d/php-fpm

#vim /etc/rc.local

加入/etc/init.d/php-fpm start

7、 添加Mongdb、Memcache扩展

#/usr/local/php/bin/pcelinstall mongo

#/usr/local/php/bin/pcelinstall mencache

8、 添加加速模块Eaccelerator(PHP5.5版本开机不用加速扩展)

tar解压eaccelerator安装包

进入源文件目录,用phpize生成configure配置文件

#/usr/local/php/bin/phpize

配置

#./configure --with-php-config=/usr/local/php/bin/php-config--enable-eaccelerator=shared

#make

#make install

9、 查看PHP-FPM是否正常工作

#/etc/init.d/php-fpmstart

#ps -ef | grep php   查看php-fpm进程

10、修改php.ini和php-fpm.confg文件,适合服务器与应用要求

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值