码迷,mamicode.com
首页 > Web开发 > 详细

php 5.6.6 源码安装配置

时间:2015-03-30 19:08:32      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:php 5.6.6 源码安装配置

php 需要安装的包

yum install -y gccgcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devellibpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibcglibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curlcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel

yum install libXpm-devel  libtidy-devel  curl-devel  db4-devel expat-devel libxslt libxslt-devel libxml2 libxml2-devel  curl 

yum installlibjpeg-devel  install libpng-develgmp-devel net-snmp-devellibxslt-devel sqlite-devel aspell-devel

yum install   libX11-devel libXext-devel libXt-devel

yum install libxslt* -y

libodb-mysql-devel   支持php调用的,从系统光盘中提取出来使用rpmv –ivh 安装,使用yum安装的话会把mysql安装上

soci-mysql-devel.

openldap openldap-devel nss_ldapopenldap-clients openldap-servers  如果配置ldap需要安装的php依赖的包

[root@web1_lamp tool]# yum  install -y libmcrypt-devel ## 这个包需要扩展源进行安装

   wget -c   http://mirrors.aliyun.com/epel/6Server/x86_64/epel-release-6-8.noarch.rpm  6以上的系统中没有这个安装包

   rpm  -ivhlibmcrypt-devel-2.5.7-5.el5.x86_64.rpm –nodeps

rpm -ivh mysql-devel-5.1.73-3.el6_5.x86_64.rpm –nodeps  使用rpm 强制安装mysql-devel 因为我不需要mysql的rpm包

http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz

 [root@web1_lamptool]# useraddphp-fpm -s /sbin/nologin -M

[root@web1_lamp tool]# cd /soft/tool/

[root@web1_lamp tool]# tarzxf libmcrypt-2.5.8.tar.gz -C /usr/local/src/

[root@web1_lamp tool]# tarzxf libiconv-1.14.tar.gz -C /usr/local/src/

[root@web1_lamp tool]# tarzxf mcrypt-2.6.8.tar.gz -C /usr/local/src/

[root@web1_lamp tool]# cd/usr/local/src/libmcrypt-2.5.8/

[root@web1_lamplibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt  是一个加密算法库

[root@web1_lamplibmcrypt-2.5.8]# make && make install

[root@web1_lamplibmcrypt-2.5.8]# cd /usr/local/src/libiconv-1.14/   字符编码转换

[root@web1_lamplibiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[root@web1_lamplibiconv-1.14]# make  &&  make install

 [root@web1_lamp mcrypt-2.6.8]# cd /soft/tool/

[root@web1_lamp tool]# tarzxf mhash-0.9.9.9.tar.gz -C /usr/local/src/

[root@web1_lamp tool]# cd/usr/local/src/mhash-0.9.9.9/

[root@web1_lampmhash-0.9.9.9]# ./configure --prefix=/usr/local/mhash

[root@web1_lampmhash-0.9.9.9]# make && make install

[root@web1_lampmhash-0.9.9.9]# cd /usr/local/src/mcrypt-2.6.8/

[root@web1_lampmcrypt-2.6.8]# ./configure --prefix=/usr/local/mcrypt--with-libiconv-prefix=/usr/local/libiconv --with-libmcrypt-prefix=/usr/local/libmcrypt

*** Could not run libmcrypt test program, checking why...

*** The test program compiled, but did not run. Thisusually means

*** that the run-time linker is not finding LIBMCRYPT orfinding the wrong

*** version of LIBMCRYPT. If it is not finding LIBMCRYPT,you‘ll need to set your

*** LD_LIBRARY_PATH environment variable, or edit/etc/ld.so.conf to point

*** to the installed location  Also, make sure you have run ldconfig if that

*** is required on your system

***

*** If you have an old version installed, it is best toremove it, although

*** you may also be able to get things to work bymodifying LD_LIBRARY_PATH

***

configure: error: *** libmcrypt was not found

 

提示让我去LD_LIBRARY_PATHenvironment variable, or edit /etc/ld.so.conf to point修改环境变量

[root@web2_lnmpmhash-0.9.9.9]# cat /etc/ld.so.conf   添加libmcrypt/lib的库位置之后 ldconfig 以下即可解决

includeld.so.conf.d/*.conf

/usr/local/libmcrypt/lib

继续报错configure: error: "You need at least libmhash 0.8.15 to compilethis program. http://mhash.sf.net/"  执行以下三行命令解决

[root@web1_lamp mcrypt-2.6.8]# exportLD_LIBRARY_PATH=/usr/local/libmcrypt/lib:/usr/local/mhash/lib

[root@web1_lamp mcrypt-2.6.8]# exportLDFLAGS="-L/usr/local/mhash/lib/ -I/usr/local/mhash/include/"

[root@web1_lamp mcrypt-2.6.8]# exportCFLAGS="-I/usr/local/mhash/include/"

在安装完mhash 之后使用ldconfig

[root@web2_lnmpmhash-0.9.9.9]# cat /etc/ld.so.conf  但是在ld.so.conf中解决不了mhash源码版本对不上的问题

includeld.so.conf.d/*.conf

/usr/local/libmcrypt/lib

/usr/local/mhash/lib

Ldconfig 更新一下

[root@web2_lnmpmcrypt-2.6.8]# ./configure --prefix=/usr/local/mcrypt--with-libiconv-prefix=/usr/local/libiconv--with-libmcrypt-prefix=/usr/local/libmcrypt 

[root@web2_lnmpmcrypt-2.6.8]#  make  && make install

 [root@web1_lamptool]#tarzxf php-5.6.6.tar\ .gz -C /usr/local/src/soft/

[root@web1_lamp tool]# cd /usr/local/src/soft/php-5.6.6/

2.5.1 php 编译

[root@web1_lamp tool]#tar zxfphp-5.6.6.tar\ .gz -C /usr/local/src/soft/

[root@web1_lamp tool]# cd /usr/local/src/soft/php-5.6.6/

[root@web1_lampphp-5.6.6]#

 

./configure  \

  --prefix=/usr/local/php \

  --with-apxs2=/usr/local/apache2/bin/apxs \

  --with-mysql=/usr/local/mysql \

 --with-config-file-path=/usr/local/php/etc \

--with-mhash=/usr/local/mhash\

--with-mcrypt=/usr/local/mcrypt\

  --enable-fpm \

--with-libxml-dir \

--with-openssl \

--with-zlib=/usr/local/zlib \

--with-curl \

--with-xmlrpc \

--with-libxml-dir \

--with-pcre-dir \

--enable-ftp \

--with-gd \

--with-jpeg-dir\

--with-png-dir\

--with-xpm-dir\

--with-freetype-dir\

--enable-gd-native-ttf\

--enable-gd-jis-conv\

--with-gmp\

--enable-intl\

--enable-mbstring\

--enable-sockets\

--enable-zip\

--enable-soap\

--enable-sockets\

--with-iconv=/usr/local/libiconv \

--with-pear\

--enable-short-tags\

--enable-mbstring\

--enable-static\

--with-xsl\

--enable-ftp\

--enable-bcmath \

--with-bz2\

--enable-inline-optimization \

--with-gettext \

--with-zend-vm=CALL\

--enable-zend-signals \

--enable-mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--enable-exif 

 

 

 

最简单直接的编译结合nginx     ./configure --enable-fpm --with-mysql

--enable-fastcgi(nginx+php编译的时候需要开启)

如果不安装rpm  -ivhlibmcrypt-devel-2.5.7-5.el5.x86_64.rpm –nodeps  的话会报错,提示libmcrypt和mhash 未安装,强制安装好之后再去执行./configure 预处理就解决了此类问题

报错:used when making a shared object; recompilewith -fPIC

/usr/lib64/libmcrypt.a: could not readsymbols: Bad value

collect2: ld returned 1 exit status

make: *** [libphp5.la] Error

64位的系统需要单独的去安装zlib的包,可以去官网下载

http://www.zlib.net/如果不安装的话就会报上面的错误编译的时候加参数CFLAGS="-O3-fPIC" ./configure  --prefix=/usr/local/zlib使用64位元编译, 继续编译还是报错。

   分析原因得出,.a  是静态结尾文件,提示我编译的时候需要加-fpci 参数,参考网站资料我指定库的位置进行编译

参考http://blog.csdn.net/cserchen/article/details/5515974

https://bugs.php.net/search.php?cmd=display&search_for=segmentation&php_os=&php_os_not=&author_email=&bug_type=&boolean=0&bug_age=0&bug_updated=0&order_by=&direction=ASC&limit=All&phpver=&cve_id=&cve_id_not=&patch=&assign=&status=All&reorder_by=ts2    php每个系统的错误信息 

https://gorn.ch/archive/2007/11/01/leopard-native-apache-with-custom-64bit-php.html  有关64位系统安装建议

经过查看我本地的libmcrypt.a 未做软链接,所以加载我静态库失败,

[root@zabbixlib64]# ll -lih  libmcrypt.so

41902lrwxrwxrwx 1 root root 18 Mar  6 20:34libmcrypt.so -> libmcrypt.so.4.4.7

解决

[root@zabbixlib]# pwd

/usr/local/libmcrypt/lib

[root@zabbixlib]# ln -s * /usr/lib64/   之后重新编译问题解决,

教训总结:一般在编译完软件之后有报错.so .a的问题的查看到对应的.a .so动态库和静态库的路径做一个软链接到/lib64  /usr/lib64 这个路径下,这是64位操作系统加载的库路径

不同的环境下搭建php需要的参数不同,根据自己的需要去选择相应的参数

备选参数

--with-mysqli=mysqlnd

--with-fpm-user=php-fpm \

--with-fpm-group=php-fpm \

--with-config-file-scan-dir=PATH   Set the path where to scan forconfiguration files  配置文件路径

--with-config-file-path=PATH      Set the path in which to look for php.ini[PREFIX/lib] php.ini 文件路径

--with-mysqli=/usr/local/mysql/bin/mysql_config \  本地的mysql 链接

--with-mysqli=FILE     Include MySQLi support.  FILE isthe path  to mysql_config.  If no value or mysqlnd is passed

--enable-mysqlnd\

--with-pdo-mysql=/usr/local/mysql  如果不指定mysqld 将使用本地连接

--enable-embedded-mysqli   使用嵌入支持不适用mysql 本地

--with-mysql-sock=SOCKPATH  如果不指定,将默认查找

--disable-fileinfo

内存小于1G 需要加这个参数--disable-fileinfo 有提示了再加,省得最后报错

--enable-intl   选择国际化标准安装

configure: error: Unable todetect ICU prefix or no failed. Please verify ICU install prefix and make sureicu-config works. 因为我选择了国际标准所以老外都喜欢libic-devel

[root@web1_lampphp-5.6.6]# yuminstall perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker perl-ExtUtils-Embed libicu-devel

[root@web2_lnmp php-5.6.6]# make &&make install  安装完信息,如果有提示警告之类的,需要解决警告之后make clean重新编译

警告处理

http://php.net/results.php?q=%60libtool&l=es&p=all

libtool: install: warning:remember to run `libtool --finish /usr/local/src/php-5.6.6/libs‘  就执行可以,参照系统提示做就行了如果开发包安装完整的话不会有报错的,这里的警告是使用libtool 创建库函数

[root@web1_lamp php-5.6.6]#  ll /usr/local/apache2/modules/*php*   检查php是否生成支持php.so 模块

-rwxr-xr-x 1 root root 31172030 Feb 28 11:01/usr/local/apache2/modules/libphp5.so

[root@web1_lamp php-5.6.6]#  grep libphp5 /usr/local/apache2/conf/httpd.conf 

LoadModule php5_module        modules/libphp5.so

2.5.2  配置php

[root@web1_lamp php-5.6.6]# cpphp.ini-production /etc/php.ini   è cp php的配置文件到/etc/php.ini

[root@web1_lamp php-5.6.6]#cpsapi/fpm/init.d.php-fpm /etc/init.d/php-fpmè配置一个启动脚本

[root@web1_lamp php-5.6.6]# chmod 755 /etc/init.d/php-fpm   è赋予执行权限

[root@web1_lamp php-5.6.6]# chkconfig --addphp-fpm  è添加到chkconfig

 [root@web1_lampphp-5.6.6]# chkconfig --list php-fpm

php-fpm         0:off  1:off   2:on    3:on   4:on    5:on    6:off

 [root@web1_lampphp-5.6.6]# cd /usr/local/php/etc/

[root@web1_lamp etc]# cpphp-fpm.conf.default php-fpm.conf è配置php-fpm 配置文件可以使用默认的就不需要修改了

[root@web1_lamp etc]# vimphp-fpm.conf è  可以使用默认的,没有需求的时候就不要去修改 

[root@web1_lamp etc]# diffphp-fpm.conf php-fpm.conf.default

listen = 20.0.0.10:9000   定位listenip地址为别人可以访问进来的ip

25c25

< pid = run/php-fpm.pid

> ;pid = run/php-fpm.pid

235c235

< pm.max_children = 50

> pm.max_children = 5

240c240

< pm.start_servers = 5   改为5的就可以查看到5个站点的进程

> pm.start_servers = 2

245c245

< pm.min_spare_servers = 3

> pm.min_spare_servers = 1

250c250

< pm.max_spare_servers = 8

> pm.max_spare_servers = 3

[root@web1_lamp etc]#/usr/local/php/sbin/php-fpm –t  è测试配置文件是否正确

[28-Feb-2015 06:44:48] NOTICE: configurationfile /usr/local/php/etc/php-fpm.conf test is successful

[root@web2_lnmp etc]# /etc/init.d/php-fpmreload

Starting php-fpm

[root@web1_lamp etc]# ps aux |grep php-fpm

root     23108  0.0  1.0 72364  5144 ?        Ss  22:47   0:00 php-fpm: masterprocess (/usr/local/php/etc/php-fpm.conf)                                                                   

nobody   23109  0.0  0.9 72364  4452 ?        S   22:47   0:00 php-fpm: poolwww                                                                                                           

nobody   23110  0.0  0.9 72364  4452 ?        S   22:47   0:00 php-fpm: poolwww                                                                                                           

nobody   23111  0.0  0.9 72364  4452 ?        S   22:47   0:00 php-fpm: poolwww                                                                                                           

nobody   23112  0.0  0.9 72364  4452 ?        S   22:47   0:00 php-fpm: poolwww                                                                                                           

nobody   23113  0.0  0.9 72364  4452 ?        S   22:47   0:00 php-fpm: poolwww                                                                                                           

root     23115  0.0  0.1 103244  864 pts/0    S+   22:47  0:00 grep php-fpm

[root@web2_lnmp etc]# ss -tunl | grep 9000

tcp    LISTEN    0      128            20.0.0.10:9000                  *:*     


本文出自 “小菜鸟” 博客,请务必保留此出处http://xiaocainiaox.blog.51cto.com/4484443/1626389

php 5.6.6 源码安装配置

标签:php 5.6.6 源码安装配置

原文地址:http://xiaocainiaox.blog.51cto.com/4484443/1626389

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!