1. 程式人生 > >centos7 編譯安裝 php7.0

centos7 編譯安裝 php7.0

1。cd /data/src

2。tar -zxvf php-7.0.32.tar.gz

3.cd /data/src/php-7.0.32

./configure --prefix=/data/softs/php --with-config-file-path=/data/softs/php/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache --enable-fpm --with-fpm-user=u1 --with-fpm-group=u1 --with-pdo-mysql --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --enable-libxml   --enable-xml --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --enable-gd-native-ttf  --enable-session  --with-gd 

4.make && make install

5.cp /data/src/php-7.0.32/php.ini-development /data/softs/php/etc/php.ini

6.cp /data/softs/php/etc/php-fpm.conf.default /data/softs/php/etc/php-fpm.conf

7.cp /data/src/php-7.0.32/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

8.cp /data/softs/php/etc/php-fpm.d/www.conf.default /data/softs/php/etc/php-fpm.d/www.conf

9.chmod +x /etc/init.d/php-fpm 

10.chkconfig --add php-fpm

11.chkconfig on php-fpm

12.service php-fpm start

13環境變數

# vi /etc/profile

PATH=$PATH:/data/server/php/bin

export PATH

# source /etc/profile

 

另:

##引數解釋

""" 安裝路徑 """

--prefix=/usr/local/php56 \

""" php.ini 配置檔案路徑 "

""

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

""" 優化選項 """

--enable-inline-optimization \

--disable-debug \

--disable-rpath \

--enable-shared \

""" 啟用 opcache,預設為 ZendOptimizer+(ZendOpcache) """

--enable-opcache \

""" FPM """

--enable-fpm \

--with-fpm-user=www \

--with-fpm-group=www \

""" MySQL """

--with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

""" 國際化與字元編碼支援 """

--with-gettext \

--enable-mbstring \

--with-iconv \

""" 加密擴充套件 """

--with-mcrypt \

--with-mhash \

--with-openssl \

""" 數學擴充套件 """

--enable-bcmath \

""" Web 服務,soap 依賴 libxml """

--enable-soap \

--with-libxml-dir \

""" 程序,訊號及記憶體 """

--enable-pcntl \

--enable-shmop \

--enable-sysvmsg \

--enable-sysvsem \

--enable-sysvshm \

""" socket & curl """

--enable-sockets \

--with-curl \

""" 壓縮與歸檔 """

--with-zlib \

--enable-zip \

--with-bz2 \

""" GNU Readline 命令列快捷鍵繫結 """

--with-readline

 

注:

1。configure error xml2-config not found. please check your libxml2 installation

檢查是否安裝了libxm包
[[email protected] software]# rpm -qa |grep  libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安裝libxml2和libxml2-devel包, yum安裝的時候發現新版本會提示更新,需要更新的可以更新,不要跳過就行了。
[[email protected] /]# yum install libxml2
[[email protected] /]# yum install libxml2-devel -y

2。Configure: error: Please reinstall the BZip2 distribution

yum install bzip2 bzip2-devel

3。Exception: `curl-config' not found -- please install the libcurl development files

yum install curl-devel -y

4。configure: error: png.h not found

If configure fails try --with-vpx-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
configure: error: png.h not found.

經查資料說是libpng,devel包沒安裝,

執行下面兩條命令即可解決

yum install libpng

yum install libpng-devel

然後重新編譯安裝就行了    

5。configure: error: mcrypt.h not found. Please reinstall libmcrypt.

yum install -y epel-release
yum install -y libmcrypt-devel
兩個不能一起安裝,因為CentOs6預設的yum源沒有 libmcrypt-devel這個包,只能藉助epel的yum源,所以先安裝epel,再安裝
libmcrypt。
6。configure: error: Please reinstall readline - I cannot find readline.h

yum -y install readline-devel

7。configure: WARNING: unrecognized options: --with-mysql

編譯php後發生warning:configure:WARNING:unrecognizedoptions:--with-mysql 只是php不支援mysql模組

./configure --help 檢視configure的正確語法,重新編譯php支援mysql,改用--with-pdo-mysql

8。configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum -y install libxslt-devel

9。configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
yum -y install net-snmp-devel

10。configure: error: Please reinstall readline - I cannot find readline.h
yum -y install readline-devel

11。configure: error: Cannot find pspell
yum -y install aspell-devel

12。checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
yum -y install unixODBC-devel

13。configure: error: Unable to detect ICU prefix or /usr/bin/icu-config failed. Please verify ICU install prefix and make sure icu-config works.
yum -y install libicu-devel

14。configure: error: utf8mime2text() has new signature, but U8TCANONICAL is missing. This should not happen. Check config.log for additional information.
yum -y install libc-client-devel

15。configure: error: freetype.h not found.
yum -y install freetype-devel

16。configure: error: xpm.h not found.
yum -y install libXpm-devel

17。configure: error: png.h not found.
yum -y install libpng-devel

18。configure: error: vpx_codec.h not found.
yum -y install libvpx-devel

19。configure: error: Cannot find enchant
yum -y install enchant-devel

20。configure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/
yum -y install libcurl-devel
 

21。configure: error: mcrypt.h not found. Please reinstall libmcrypt.
wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
tar zxf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make && make install
 

22。Cannot find imap
ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so

23。configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
yum -y install libc-client-devel

24。Cannot find ldap.h
yum -y install openldap
yum -y install openldap-devel

25。configure: error: Cannot find ldap libraries in /usr/lib
cp -frp /usr/lib64/libldap* /usr/lib/

26。configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

yum -y install postgresql-devel

27。configure: error: Please reinstall the lib curl distribution
yum -y install curl-devel

28。configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
yum -y install net-snmp-devel

29。configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum -y install libxslt-devel

30。checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution
yum -y install bzip2-devel

31。checking for cURL support… yes checking if we should use cURL for url streams… no checking for cURL in default path… not found configure: error: Please reinstall the libcurl distribution – easy.h should be in/include/curl/
yum -y install curl-devel

32。checking for curl_multi_strerror in -lcurl… yes checking for QDBM support… no checking for GDBM support… no checking for NDBM support… no configure: error: DBA: Could not find necessary header file(s).
yum -y install db4-devel

33。checking for fabsf… yes checking for floorf… yes configure: error: jpeglib.h not found.
yum -y install libjpeg-devel

34。checking for fabsf… yes checking for floorf… yes checking for jpeg_read_header in -ljpeg… yes configure: error: png.h not found.
yum -y install libpng-devel

45。checking for png_write_image in -lpng… yes If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.
Reconfigure your PHP with the following option. --with-xpm-dir=/usr
checking for png_write_image in -lpng… yes configure: error: libXpm.(a|so) not found.
yum -y install libXpm-devel

46。checking for bind_textdomain_codeset in -lc… yes checking for GNU MP support… yes configure: error: Unable to locate gmp.h
yum -y install gmp-devel

47。checking for utf8_mime2text signature… new checking for U8T_DECOMPOSE… configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
yum -y install libc-client-devel

48。checking for LDAP support… yes, shared checking for LDAP Cyrus SASL support… yes configure: error: Cannot find ldap.h
yum -y install openldap-devel

49。checking for mysql_set_character_set in -lmysqlclient… yes checking for mysql_stmt_next_result in -lmysqlclient… no checking for Oracle Database OCI8 support… no checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!
yum -y install unixODBC-devel

50。checking for PostgreSQL support for PDO… yes, shared checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
yum -y install postgresql-devel

51。checking for sqlite 3 support for PDO… yes, shared checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext checking for sqlite3 files in default path… not found configure: error: Please reinstall the sqlite3 distribution
yum -y install sqlite-devel

52。checking for utsname.domainname… yes checking for PSPELL support… yes configure: error: Cannot find pspell
yum -y install aspell-devel

53。checking whether to enable UCD SNMP hack… yes checking for default_store.h… no

checking for kstat_read in -lkstat… no checking for snmp_parse_oid in -lsnmp… no checking for init_snmp in -lsnmp… no configure: error: SNMP sanity check failed. Please check config.log for more information.
yum -y install net-snmp-devel

54。checking whether to enable XMLWriter support… yes, shared checking for xml2-config path… (cached) /usr/bin/xml2-config checking whether libxml build works… (cached) yes checking for XSL support… yes, shared configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum -y install libxslt-devel

55。configure: error: xml2-config not found. Please check your libxml2 installation.
yum -y install libxml2-devel

56。checking for PCRE headers location… configure: error: Could not find pcre.h in /usr
yum -y install pcre-devel

57。configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore!
yum -y install mysql-devel

58。checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h' not found!
yum -y install unixODBC-devel

59。checking for pg_config… not found configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
yum -y install postgresql-devel

60。configure: error: Cannot find pspell
yum -y install pspell-devel

61。configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
yum -y install net-snmp-devel

62。configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
yum -y install libxslt-devel