非常经常用到的一个编译,统一了下,这回可以直接复制黏贴就可以做完啦,不然还需要找参数,真悲惨 。
编译PHP所需要的支持
yum install gcc
yum install libxml2-devel curl-devel libjpeg libjpeg-devel libpng-devel freetype-devel.x86_64 mysql-devel
yum install freetype-devel.x86_64 freetype.x86_64
yum install libjpeg libjpeg-devel
下载PHP:wget http://us1.php.net/distributions/php-5.3.28.tar.bz2
tar -jxf php-5.3.28.tar.bz2
cd php-5.3.28
./configure –prefix=/usr/local/php-5.3.28 –enable-fpm –with-mysql –with-zlib –with-config-file-path=/usr/local/php5.3.28/etc –with-pdo-mysql –with-libdir=lib64 –with-gd –with-jpeg-dir=/usr/lib –with-png-dir=/usr/lib –enable-mbstring –enable-gd-native-ttf –enable-xml –with-freetype-dir –with-curl –enable-ftp –enable-zip –with-mcrypt –enable-mbstring –enable-json
出现失败
checking for alloca… (cached) yes
checking for 8-bit clean memcmp… yes
checking for stdarg.h… (cached) yes
checking for mcrypt support… yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt
rpm -qa | grep libmcrypt
libmcrypt-2.5.7-5.el5
libmcrypt-2.5.8-4.el5.centos
有但是失败,上面的是用yum安装,不对,难道需要去下载包编译??试试呗:
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz 安装:
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install
然后重新编译PHP,O(∩_∩)O哈哈~成功过了
# make
# make install
# cp php.ini-production /usr/local/php5.3.28/etc/php.ini
# cp sapi/fpm/php-fpm.conf /usr/local/php5.3.28/etc/
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod 755 /etc/init.d/php-fpm
# cd /usr/local/php5.3.28/etc/
# vi php-fpm.conf
将[global]属性里面的pid = run/php-fpm.pid 去掉注释。
将[www]属性里面的 user = nobody group = nobody 的nobody改为nginx
将pm.min_spare_servers = 5 去掉注释
将pm.max_spare_servers = 35 去掉注释
将pm.start_servers = 20 去掉注释
设置memory_limit = 128M
date.timezone = Asia/Shanghai
vi /etc/profile
PATH=$PATH:/usr/local/php5.3.28/bin:/usr/local/php5.3.28/sbin
source /etc/profile
添加nginx php-fpm的支持
vi /etc/nginx/fastcgi_params
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
现在我们来解释下编译的一些参数
./configure –prefix=/usr/local/php-5.3.28 安装的路径
–enable-fpm 打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序
–with-mysql
–with-zlib 打开zlib库的支持
–with-config-file-path=/usr/local/php5.3.28/etc
–with-pdo-mysql
–with-libdir=lib64
–with-gd 打开gd库的支持
–with-jpeg-dir=/usr/lib 打开对jpeg图片的支持
–with-png-dir=/usr/lib 打开对png图片的支持
–enable-mbstring 多字节,字符串的支持
–enable-gd-native-ttf 支持TrueType字符串函数库
–enable-xml 打开xml支持
–with-freetype-dir 打开对freetype字体库的支持
–with-curl 打开curl浏览工具的支持
–enable-ftp 支持ftp扩展
–enable-zip 支持zip扩展
–with-mcrypt 支持mcrypt扩展
–enable-mbstring 支持mbstring扩展
–enable-json 支持json扩展