yum -y groupinstall "X Software Development Desktop Platform Development"
安装这些包就可以了
yum install libmcrypt libmcrypt-devel mhash mhash-devel opensll openssl-devel mariadb-devel libxml2 libxml2-devel bzip2 bzip2-devel curl-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel readline readline-devel libxslt libxslt-devel
2、编译安装php-5.6.32
首先下载源码包至本地目录,下载位置ftp://172.16.0.1/pub/Sources/new_lamp。
# tar xf php-5.6.32.tar.gz
# cd php-5.6.32
# ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-openssl --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --enable-zip --enable-mysqlnd --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --with-mysqli --with-pdo-mysql=mysqlnd --with-gd --enable-gd-native-ttf --with-mhash
说明:如果使用PHP5.3以上版本,为了链接MySQL数据库,可以指定mysqlnd,这样在本机就不需要先安装MySQL或MySQL开发包了。mysqlnd从php 5.3开始可用,可以编译时绑定到它(而不用和具体的MySQL客户端库绑定形成依赖),但从PHP 5.4开始它就是默认设置了。
# ./configure --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd
# make
# make intall
为php提供配置文件:
# cp php.ini-production /etc/php.ini
3、配置php-fpm
为php-fpm提供systemd脚本,并将其添加/usr/lib/systemd/system/fpm.service:
[unit]
Description=php-fpm
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
为php-fpm提供配置文件:
# cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf
编辑php-fpm的配置文件:
# vim /usr/local/php5/etc/php-fpm.conf
配置fpm的相关选项为你所需要的值,并启用pid文件(如下最后一行):
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
pid = /usr/local/php5/var/run/php-fpm.pid
接下来就可以启动php-fpm了:
# systemctl start fpm.service
提供各种php源码 pecl.php.net/
提供ICU4C源码
http://download.icu-project.org/files/icu4c/49rc/icu4c-49_rc-src.tgz
提供intl源码
http://pecl.php.net/package/intl
pecl 方式安装
执行 # /usr/local/php/bin/pecl install intl-3.0.0
安装过程中会让您指定ICU库的位置,我的位置是 /usr/local/icu ,安装完成后将 extension=intl.so 加入到php.ini文件中,然后执行 /etc/init.d/php-fpm restart 使php.ini配置生效。
最后用 # php -m | grep intl 或 phpinfo() 查看intl扩展是否安装成功
源码方式安装
[root@tangrucheng-linux soft]# tar -xzf intl-3.0.0.tgz
[root@tangrucheng-linux soft]# cd intl-3.0.0 3. 进入文件夹后,首先运行 phpize 来准备编译扩展的环境
[root@tangrucheng-linux intl-3.0.0]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525 4. 运行后,我们运行 ./configure 脚本来进行配置 --with-php-config 这个参数是告诉配置脚本 php-config 这个程序的路径。
[root@tangrucheng-linux intl-3.0.0]# ./configure -h
[root@tangrucheng-linux intl-3.0.0]# ./configure --enable-intl --with-icu-dir=/usr/local/icu/ --with-php-config=/usr/local/php/bin/php-config
5. 这时用make来编译扩展
6. 安装完成后将 extension=intl.so 加入到php.ini文件中,然后执行 /etc/init.d/php-fpm restart 使php.ini配置生效。
进入php源码目录
cd /usr/local/php-5.6.32/ext/pdo_mysql
运行phpize
/usr/local/php/bin/phpize
配置
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr --with-zlib-dir=/usr/lib
make && make install
安装memcache扩展
yum install "memcached", "libmemcached";
下载源码 http://pecl.php.net/get/memcache-3.0.8.tgz
tar -xf memcache-3.0.8.tgz
cd memcache-3.0.8.tgz
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
GD
yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
cd /usr/local/php-5.6.32/ext/gd
/usr/local/php/bin/phpize
./configure --with-png-dir --with-freetype-dir --with-jpeg-dir --with-gd --with-php-config=/usr/local/php/bin/php-config
make && make install
ImageMagick
yum install ImageMagick-deve ImageMagick
http://pecl.php.net/get/imagick-3.4.3.tgz
cd /usr/local/imagick-3.4.3/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick
make && make install
mysqli
cd /usr/local/php-5.3.36/ext/mysqli //到php文件ext下的mysqli
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-mysqli=/usr/bin/mysql_config
报错
/usr/local/php-5.5.38/ext/mysqli/mysqli_api.c:36:47: error: ext/mysqlnd/mysql_float_to_double.h: No such file or directory
make: *** [mysqli_api.lo] Error 1
解决方法:
修改 vim /usr/local/php-5.5.38/ext/mysqli/mysqli_api.c文件
将#include "ext/mysqlnd/mysql_float_to_double.h" 修改为绝对路径:
#include "/usr/local/php-5.5.38/ext/mysqlnd/mysql_float_to_double.h"
修改php.ini文件中的设置,找打[data]下的;date.timezone = 选项,去掉前面的引号,修改为:date.timezone = PRC,然后重启Apache。