当前位置: 首页 > news >正文

linux7下centos6.8版本完全编译php7.17与nginx

yum install -y lrzsz 安装文件传输程序

yum install -y gcc-c++ 安装gcc c++ 编译器

一,安装了perl5 ,因为bison和openssl都依赖它

./configure.gnu --prefix=/usr/local/related/perl

make && make install

先开始nginx的安装

二,安装 pcre

./configure --prefix=/usr/local/related/pcre

make && make install

三,安装zlib
openssl安装种也会检测zlib是否安装,所以先安装它。

./configure --prefix=/usr/local/related/zlib

make && make install

四,安装openssl

因为openssl version -a 后发现系统已有安装openssl所以这里暂不处理看下是否能行,默认版本为(OpenSSL 1.0.1e-fips 11 Feb 2013
);

编译与安装 OpenSSL

prefix 是安装目录,openssldir 是配置文件目录,另外建议安装两次,shared 作用是生成动态连接库。

wget ftp://ftp.openssl.org/source/openssl-1.0.0c.tar.gz

tar -zxf openssl-1.0.0c.tar.gz

cd openssl-1.0.0c/

./config  --prefix=/usr/local --openssldir=/usr/local/ssl

make && make install

./config shared --prefix=/usr/local --openssldir=/usr/local/ssl

make clean

make && make install



五,安装nginx

./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.41 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.1.0f


开始安装php
 

这里说下,最好是先安装mysql 因为在安装php时可以直接指定mysql所在目录,否则还需要后期再次配置。但是因为mysql编译较长,这里为了测试,直接安装php先。

如果在安装一个软件包时,最后输入sudo make install命令后,出现以下错误信息:
error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
但是在/usr/local/lib下却能找到libiconv.so.2,解决方法是将/usr/local/lib路径添加到/etc/ld.so.conf文件中,然后用sudo ldconfig命令加载,再重新输入sudo make install命令就可以了。
include ld.so.conf.d/*.conf
/usr/local/lib

sudo make ZEND_EXTRA_LIBS='-liconv'

 

 

1,安装libxml2

 

 

下载地址:http://xmlsoft.org/sources/

./configure --prefix=/usr/local/related/libxml2 --with-zlib=/usr/local/related/zlib
 

make && make install

如有报错:libxml.c:14:20: 致命错误:Python.h:没有那个文件或目录
缺失python-devel开发包所导致,python.h存在于python-devel开发包

解决办法:

  yum install python3.4-devel

勤苦修行得自在,道力有边亦无边!

 

2,安装libpng,安装gd时需要指定它

 

下载地址:http://www.libpng.org/pub/png/libpng.html

如果是xz结尾,使用 xz -d ***解压出

./configure --prefix=/usr/local/related/libpng --with-zlib-prefix=/usr/local/related/zlib

configure: error: zlib not installed

执行以下命令:

#export LDFLAGS="-L/usr/local/zlib/lib"
#export CPPFLAGS="-I/usr/local/zlib/include"

或者这样也能解决  ./configure --prefix=/usr/local/related/libpng LIBS=-L/usr/local/related/zlib/lib CPPFLAGS=-I/usr/local/related/zlib/include

3,安装libjpeg,安装gd时需要指定它

下载地址:https://sourceforge.net/projects/libjpeg/

以及 :http://libjpeg.sourceforge.net/

新版地址:http://www.imagemagick.org/download/delegates/

务必下载tar.gz格式

./configure --prefix=/usr/local/related/libjpeg

make && make install

4,安装freetype,因为安装gd时需要它

下载地址:https://www.freetype.org/download.html

以下指定了zlib和libpng的安装路径:

./configure --prefix=/usr/local/related/freetype ZLIB_LIBS=-L/usr/local/related/zlib/lib ZLIB_CFLAGS=-I/usr/local/related/zlib/include LIBPNG_LIBS=-L/usr/local/related/libpng/lib LIBPNG_CFLAGS=-I/usr/local/related/libpng/include

 

也可以把bzip2安装上用来压缩字体

地址:https://fossies.org/linux/misc/bzip2-1.0.6.tar.gz/

安装方式不同其他:

make -f Makefile-libbz2_so //-f 标志是使bzip2 根据另一个Makefile来编译,就是Makefile-libbz2_so文件,创建一个动态的libbz.so库文件,然后把bzip2工具连接到这个库上

还可以把HarfBuzz 安装上

地址:https://www.freedesktop.org/wiki/Software/HarfBuzz/

5,安装gd

下载地址:https://libgd.github.io/

以及 :https://github.com/libgd/libgd/releases

以下指定了zlib和libpng,libjpeg,freetype的安装路径:

注意:这里必须要指定zlib的宏,不然jpeg和freetype也会显示support .... no


./configure --prefix=/usr/local/related/libgd  LIBS=-L/usr/local/related/zlib/lib CPPFLAGS=-I/usr/local/related/zlib/include --with-png=/usr/local/related/libpng --with-jpeg=/usr/local/related/libjpeg --with-freetype=/usr/local/related/freetype

 

我安装的是Libgd-2.2.5 如果安装时报错:

ft2build.h:没有那个文件或目录

或者:

freetype/config/ftheader.h: No such file or directory

建议软连一下freetype的安装路径到usr/include 下,我这里是:

ln -s /usr/local/related/freetype-2.9/ usr/local/include/freetype

然后再make即可。

还有:

PHP7推荐安装libzip 地址:https://libzip.org/download/libzip-1.5.1.tar.gz

tar -zxf 1.5.1.tar.gz

cd libzip-1.5.1

mkdir build

cd build

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/related/libzip-1.5.1 -DZLIB_INCLUDE_DIR=/usr/local/related/zlib-1.2.11/include/  -DZLIB_LIBRARY=/usr/local/related/zlib-1.2.11/lib/libz.so -DOPENSSL_ROOT_DIR=/usr/local/related/openssl-1.0.2p

注意必须指定DZLIB和DOPENSSL的路径,其中DZLIB要指定到具体libz.so文件 ,

如果有问题zip_open in -lzip... no ,

checking for libzip... from pkgconfig: version 0.11.2 found in /usr/lib64
checking for zip_open in -lzip... no
configure: error: could not find usable libzip

那就别指定安装目录了,或者试试:

# 添加搜索路径到配置文件
echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
# 更新配置
ldconfig -v

或者:

PKG_CONFIG_PATH的方式来解决,即增加除默认路径/usr/local/lib以外64位机器下lib64的路径的pkgconfig信息,交给程序自己抽取位置。

具体的,就是添加这样一段:

PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \
./configure --prefix=/usr/local/php7 --other-options

6, 到此,测试一下安装php

./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-libxml-dir=/usr/local/related/libxml2 \
--with-openssl=/usr/local/related/openssl \
--with-zlib-dir=/usr/local/related/zlib \
--disable-debug \
--with-mysqli=mysqlnd  \
--with-pdo-mysql=mysqlnd \
--with-curl=/usr/local/related/curl \
--with-png-dir=/usr/local/related/libpng \
--with-jpeg-dir=/usr/local/related/libjpeg \
--with-iconv \
--with-pcre-regex \
--enable-bcmath \
--enable-ftp \
--enable-sockets \
--enable-mbstring \
--enable-mbregex \
--with-gd \
--enable-gd-native-ttf\
--enable-soap \
--enable-shmop \
--enable-sysvsem\
--with-mcrypt=/usr/local/related/libmcrypt \
--with-xsl=/usr/local/related/libxslt \
--enable-zip \

--with-libzip \

 

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-libxml-dir=/usr/local/related/libxml2-2.98/ --with-openssl-dir=/usr/local/related/openssl-1.0.2p/ --with-zlib-dir=/usr/local/related/zlib-1.2.11 --disable-debug --with-mysqli=mysqlnd  --with-pdo-mysql=mysqlnd --with-curl=/usr/local/related/curl-7.54.1/ --with-png-dir=/usr/local/related/libpng-1.6.35/ --with-jpeg-dir=/usr/local/related/jpeg-9c --with-iconv --with-pcre-regex --enable-bcmath --enable-ftp --enable-sockets --enable-mbstring --enable-mbregex --with-gd  --enable-soap --enable-shmop --enable-sysvsem --with-xsl=/usr/local/related/libxslt-1.1.32/ --enable-zip --with-freetype-dir=/usr/local/related/freetype-2.9.1/ -with-pcre-dir=/usr/local/related/pcre-8.41/ --with-libzip=/usr/local/related/libzip-1.5.1/ --with-bz2=/usr/local/

提示freetype-config not found  ,

安装 :yum install -y freetype-devel ,应该有其他办法。

兼容性

因为 APCu 5.1.0 开始,不再使用 apc_ 相关语句来识别了,而使用 apcu_ 但是一些软件并没有跟进,所以我们还需要 apcu_bc 来兼容旧的的语句。

安装方法和上述两种相同。

 

这里虽然mysql还未安装,但应指定使用mysqlnd作为驱动,在php5.3开始已内置这驱动,不需要先安装mysql就能使用只需声明即可:

 

--with-mysql=mysqlnd  \         --此项已不赞成使用

--with-mysqli=mysqlnd  \

--with-pdo-mysql=mysqlnd \

mysqlnd一些新的或增强的功能
增强的持久连接
引入特有的函数mysqli_fetch_all()

引入一些性能统计函数 mysqli_get_cache_stats(), mysqli_get_client_stats(), 

mysqli_get_connection_stats(),

使用上述函数,可很容易分析mysql查询的性能瓶颈!

SSL支持(从php 5.3.3开始有效)

压缩协议支持

命名管道支持(php 5.4.0开始有效)


报错 :configure: error: xml2-config not found. Please check your libxml2 installation.
加入:--with-libxml-dir=/usr/local/related/libxml2
报错:configure: error: Cannot find OpenSSL's libraries
加入:--with-openssl=/usr/local/related/openssl \
报错:configure: error: Cannot find libz
加入:--with-zlib-dir=/usr/local/related/zlib
报错:checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/
加入:
1,首先安装curl,,wget https://curl.haxx.se/download/curl-7.54.1.tar.gz ,, ./configure --prefix=/usr/local/related/curl --with-ssl=/usr/local/related/openssl --with-zlib=/usr/local/related/zlib
2, 加入 :--with-curl=/usr/local/related/curl \

安装它的时候建议先安装libssh2 ,然后能指定--with-ssh

下载 :https://www.libssh2.org/,

可能报错:

checking for libssl... no
configure: error: No crypto library found!


这是因为openssl没有默认安装而是指定了路径所以需要指定openssl的宏,同时使用zlib压缩,所以也指定了zlib

LDFLAGS 告诉安装的软件怎么吃这个库

LDFLAGS告诉链接器从哪里寻找库文件,LIBS告诉链接器要链接哪些库文件

安装 :

./configure --prefix=/usr/local/related/libssh2-1.8.0 --with-openssl --with-libz CPPFLAGS="-I/usr/local/related/openssl-1.0.2p/include -I/usr/local/related/zlib-1.2.11/include" LDFLAGS="-L/usr/local/related/openssl-1.0.2p/lib -L/usr/local/related/zlib-1.2.11/lib"

 

 


报错:jpeglib.h not found
加入:--with-jpeg-dir=/usr/local/related/libjpeg

报错:configure: error: png.h not found.
加入 :--with-png-dir=/usr/local/related/libpng \

报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

 

加入:

 

地址:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/

1,首先安装libmcrypt,,./configure --prefix=/usr/local/related/libmcrypt
2,--with-mcrypt=/usr/local/related/libmcrypt \

报错:configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

加入:

下载地址 :http://www.linuxfromscratch.org/blfs/view/svn/general/libxslt.html

1,安装libxslt,,./configure --prefix=/usr/local/related/libxslt --with-libxml-prefix=/usr/local/related/libxml2 --with-libxml-include-prefix=/usr/local/related/libxml2/include --with-libxml-libs-prefix=/usr/local/related/libxml2/lib --with-libxml-src=/usr/local/src/libxml2-2.8.0
2,加入:--with-xsl=/usr/local/related/libxslt \

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
!!!大功告成!!!
总结:善用./configure --help

相关文章:

  • linux7下centos6.8版本完全编译php7.17与nginx --后续,配置nginx.conf与php-fpm.conf,www.conf
  • jquery将serializeArray转为可用的json对象
  • PHP用户登录后跳转回上一访问页面的实现思路及代码
  • ckeditor 的简单调用
  • centos下的中文分词coreseek-4.1的编译安装与基本配置
  • linux下php支持sphinx的扩展安装
  • sphinx增量索引和主索引来实现索引的实时更新
  • 一个可用的coreseek以及sphinx的csft.conf配置
  • PHP获取用户真实 IP , 淘宝IP接口获得ip地理位置
  • PHP攻击网站防御代码-以及攻击代码反译
  • coreseek及sphinx的.conf典型简单配置
  • PHP 对sphinx的api调用
  • Sphinx配置文件详解
  • 单独编译安装php的mysqli,pdo_mysql,mysqlnd扩展
  • PDO方式操作MYSQL的使用
  • 《Javascript高级程序设计 (第三版)》第五章 引用类型
  • 【腾讯Bugly干货分享】从0到1打造直播 App
  • 2017-08-04 前端日报
  • C++11: atomic 头文件
  • Java新版本的开发已正式进入轨道,版本号18.3
  • JS学习笔记——闭包
  • Laravel5.4 Queues队列学习
  • linux学习笔记
  • MYSQL 的 IF 函数
  • Netty 框架总结「ChannelHandler 及 EventLoop」
  • Python连接Oracle
  • Python中eval与exec的使用及区别
  • Spring思维导图,让Spring不再难懂(mvc篇)
  • vue学习系列(二)vue-cli
  • Wamp集成环境 添加PHP的新版本
  • 安卓应用性能调试和优化经验分享
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 使用API自动生成工具优化前端工作流
  • 思否第一天
  • 一些关于Rust在2019年的思考
  • 因为阿里,他们成了“杭漂”
  • 中国人寿如何基于容器搭建金融PaaS云平台
  • Oracle Portal 11g Diagnostics using Remote Diagnostic Agent (RDA) [ID 1059805.
  • 京东物流联手山西图灵打造智能供应链,让阅读更有趣 ...
  • ​卜东波研究员:高观点下的少儿计算思维
  • ​学习一下,什么是预包装食品?​
  • ​云纳万物 · 数皆有言|2021 七牛云战略发布会启幕,邀您赴约
  • (4)事件处理——(6)给.ready()回调函数传递一个参数(Passing an argument to the .ready() callback)...
  • (C语言)fread与fwrite详解
  • (c语言)strcpy函数用法
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (Redis使用系列) Springboot 在redis中使用BloomFilter布隆过滤器机制 六
  • (超简单)构建高可用网络应用:使用Nginx进行负载均衡与健康检查
  • (分享)自己整理的一些简单awk实用语句
  • (附表设计)不是我吹!超级全面的权限系统设计方案面世了
  • (论文阅读26/100)Weakly-supervised learning with convolutional neural networks
  • (强烈推荐)移动端音视频从零到上手(上)
  • (一)搭建springboot+vue前后端分离项目--前端vue搭建
  • (原創) 未来三学期想要修的课 (日記)
  • (转) RFS+AutoItLibrary测试web对话框