centos7 编译安装 php7.0

准备:

来添加 jpeg 格式文件支持吧。

#下载jpeg扩展包
wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz 
#解压缩扩展包
tar -zxvf  jpegsrc.v8b.tar.gz 
#安装
cd jpeg-8b
./configure --prefix=/data/softs/jpeg --enable-shared --enable-static 
make && make install

php编译的时候:

./configure --prefix=/data/softs/php --with-config-file-path=/data/softs/php/etc --enable-fpm --with-fpm-user=u1 --with-fpm-group=u1 --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mcrypt --with-openssl --enable-xml --enable-zip --with-readline --enable-gd-native-ttf --with-gd --with-jpeg-dir=/data/softs/jpeg/

 yum install libjpeg-devel
    yum install freetype-devel

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-fpm --with-fpm-user=u1 --with-fpm-group=u1 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-mcrypt --with-jpeg-dir=/usr --with-freetype-dir=/usr --with-png-dir --enable-libxml --enable-xml --with-zlib --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --enable-opcache-file --with-readline

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包
[root@rh-linux software]# rpm -qa |grep  libxml2
libxml2-2.6.26-2.1.12
libxml2-python-2.6.26-2.1.12
重新安装libxml2和libxml2-devel包, yum安装的时候发现新版本会提示更新,需要更新的可以更新,不要跳过就行了。
[root@rh-linux /]# yum install libxml2
[root@rh-linux /]# 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=


If configure fails try --with-jpeg-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

 

你可能感兴趣的:(php)