内网源码安装php

国外各种rpm包依赖:http://rpmfind.net/linux/rpm2html/search.php?query=libxml2
国内各种rpm包:http://mirrors.163.com/centos/6/os/x86_64/Packages/
http://mirrors.aliyun.com/centos/7/os/x86_64/Packages/

1.外网下载源码:http://cn2.php.net/distributions/php-7.2.1.tar.gz
  a.转移到内网解压编译:tar -zxvf php-7.2.1.tar.gz -C /opt/php-7.2.1
  b.切换到解压后目录:cd /php-7.2.1
  c.预编译:./configure --prefix=/usr/local/php --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64

    问题:显示没有gcc cc
    解决:外网下载gcc源码:http://ftp.gnu.org/gnu/gcc/gcc-4.5.1/gcc-4.5.1.tar.bz2
    转移内网解压:tar -jxvf ./gcc-4.5.1.tar.bz2
    建立安装目录:mkdir /usr/local/gcc-4.5.1 && cd /usr/local/gcc-4.5.1
    编译:make && make install
    失败:提示没有gcc cc (想来也是,我TM没有编译器还下源码,操了)
    解决:下载rmp包安装:https://pan.baidu.com/s/1ujT3UAISXEsYvrKVwZeZpA 密码:1v2d
    rpm包转移到内网,切换到该目录下安装:rpm -ivh *.rpm --nodeps --force
    也可以顺序:
    rpm -ivh mpfr-3.1.1-4.el7.x86_64.rpm


    rpm -ivh libmpc-1.0.1-3.el7.x86_64.rpm


    rpm -ivh kernel-headers-3.10.0-862.el7.x86_64.rpm


    rpm -ivh glibc-headers-2.17-222.el7.x86_64.rpm


    rpm -ivh glibc-devel-2.17-222.el7.x86_64.rpm


    rpm -ivh cpp-4.8.5-28.el7.x86_64.rpm


    rpm -ivh gcc-4.8.5-28.el7.x86_64.rpm
    安装结束:gcc -v 出现如下成功
      ne=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
      Thread model: posix
      gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)

  d.再次预编译: ./configure --prefix=/usr/local/php --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64
    失败-问题:
    checking libxml2 install dir... no
    checking for xml2-config path...
    configure: error: xml2-config not found. Please check your libxml2 installation.
    缺少 libxml2 这是一个解析xml的模块,php依赖,那就看看有没有吧
      SIS3.0.44.0 ~ # rpm -qa |grep libxml2
      libxml2-devel-2.9.1-6.el7_2.3.x86_64
      libxml2-python-2.9.1-5.el7_0.1.x86_64
    我发现我有,但是为啥不行?
      检查:xml2-config 文件是否存在
        SIS3.0.44.0 ~ # find / -name "xml2-config"
        SIS3.0.44.0 ~ #
    并没有。。。。。。。。
    那就下载安装吧!可是坑爹的只能外网自己下载源码编译或者rpm包
      libxm2及其后续可能出现的依赖包:https://pan.baidu.com/s/1CLezz1UR44ScLl6MEI51PQ 密码:0e0b
      下载好:libxml2-2.9.1-6.el7_2.3.x86_64.rpm
        rpm -ivh libxml2-2.9.1-6.el7_2.3.x86_64.rpm
        出现centos7 conflicts with file from package 问题
        rpm -ivh --replacefiles libxml2-2.9.1-6.el7_2.3.x86_64.rpm
        后续所有出现 conflicts with file from pachage 都加参数 --replacefiles
      然后出现依赖什么:xz-libs、zlib
      同理libxml2-devel 包安装出现:xz-devel、zlib-devel 或者其他依赖时自己去下载吧!同理解决

    装好全部依赖解决后:
      SIS3.0.44.0 /data/shiqi # rpm -qa |grep libxml2
      libxml2-devel-2.9.1-6.el7_2.3.x86_64
      libxml2-python-2.9.1-5.el7_0.1.x86_64
      libxml2-2.9.1-5.el7_0.1.x86_64
      libxml2-2.9.1-6.el7_2.3.x86_64
     后面两个就是我装的了,有了
      SIS3.0.44.0 /data/shiqi # find / -name "xml2-config"
      /usr/bin/xml2-config
    然后啥都有了

  e.再次预编译Php:./configure --prefix=/usr/local/php --with-zlib --enable-zip --with-openssl --enable-fpm --enable-mbstring --with-libdir=lib64
  错误:我CNM傻逼内网有完没完
    configure: error: Cannot find OpenSSL's evp.h

  编译命令修改为:./configure --prefix=/usr/local/php --with-zlib --enable-zip --with-openssl-dir=/usr/include/openssl --enable-fpm --enable-mbstring --with-libdir=lib64

2.终于TM结束了
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands

3.make && make install

make
make install

cp php.ini-production /usr/local/php/lib/php.ini
cp sapi/fpm/php-fpm /etc/init.d/php-fpm
#添加执行权限
chmod +x /etc/init.d/php-fpm
#php-fpm的配置文件
cp php.ini-production /usr/local/php.ini (此路径由编译时 --with-config-file-path=/usr/local/决定)
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

#设置默认启动php-fpm子进程数和最大启动数
vim /usr/local/php/etc/php-fpm.d/www.conf
pm.max_children = 200
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 30

#设置环境变量
vim /etc/profile
#最后一行加入
export PATH=/usr/local/php/bin:$PATH

#刷新环境变量
source /etc/profile

#启动
/etc/init.d/php-fpm

 

posted @ 2020-04-28 12:58  G1733  阅读(511)  评论(0编辑  收藏  举报