溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

php 5.6.6 源碼安裝配置

發(fā)布時間:2020-06-16 17:48:54 來源:網(wǎng)絡(luò) 閱讀:3116 作者:wangxing0122 欄目:web開發(fā)

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調(diào)用的,從系統(tǒng)光盤中提取出來使用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以上的系統(tǒng)中沒有這個安裝包

   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/   字符編碼轉(zhuǎn)換

[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修改環(huán)境變量



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

includeld.so.conf.d/*.conf

/usr/local/libmcrypt/lib

繼續(xù)報錯configure: error: "You need at least libmhash 0.8.15 to compilethis program. http://mhash.sf.net/"  執(zhí)行以下三行命令解決

[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

 

 

 

最簡單直接的編譯結(jié)合nginx     ./configure --enable-fpm --with-mysql

--enable-fastcgi(nginx+php編譯的時候需要開啟)

如果不安裝rpm  -ivhlibmcrypt-devel-2.5.7-5.el5.x86_64.rpm –nodeps  的話會報錯,提示libmcrypt和mhash 未安裝,強制安裝好之后再去執(zhí)行./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位的系統(tǒng)需要單獨的去安裝zlib的包,可以去官網(wǎng)下載

http://www.zlib.net/如果不安裝的話就會報上面的錯誤編譯的時候加參數(shù)CFLAGS="-O3-fPIC" ./configure  --prefix=/usr/local/zlib使用64位元編譯, 繼續(xù)編譯還是報錯。

   分析原因得出,.a  是靜態(tài)結(jié)尾文件,提示我編譯的時候需要加-fpci 參數(shù),參考網(wǎng)站資料我指定庫的位置進行編譯

參考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每個系統(tǒng)的錯誤信息

https://gorn.ch/archive/2007/11/01/leopard-native-apache-with-custom-64bit-php.html  有關(guān)64位系統(tǒng)安裝建議

經(jīng)過查看我本地的libmcrypt.a 未做軟鏈接,所以加載我靜態(tài)庫失敗,

[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/   之后重新編譯問題解決,

教訓總結(jié):一般在編譯完軟件之后有報錯.so .a的問題的查看到對應的.a .so動態(tài)庫和靜態(tài)庫的路徑做一個軟鏈接到/lib64  /usr/lib64 這個路徑下,這是64位操作系統(tǒng)加載的庫路徑

不同的環(huán)境下搭建php需要的參數(shù)不同,根據(jù)自己的需要去選擇相應的參數(shù)

備選參數(shù)

--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

內(nèi)存小于1G 需要加這個參數(shù)--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'  就執(zhí)行可以,參照系統(tǒng)提示做就行了如果開發(fā)包安裝完整的話不會有報錯的,這里的警告是使用libtool 創(chuàng)建庫函數(shù)

[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   è賦予執(zhí)行權(quán)限

[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                  *:*     


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI