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

时间:2022-10-14 12:28:14
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先。


1,安装libxml2
./configure --prefix=/usr/local/related/libxml2 --with-zlib=/usr/local/related/zlib


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

./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时需要指定它

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

make && make install

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

以下指定了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


5,安装gd

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

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


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-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-soap \
--with-mcrypt=/usr/local/related/libmcrypt \
--with-xsl=/usr/local/related/libxslt \
--enable-zip \
--disable-fileinfo

报错 :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 \

报错: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.
加入:
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
加入:
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