每一个你不满意的现在,都有一个你不努力的曾经。

PHP74编译安装


PHP74编译安装

1)下载PHP

https://www.php.net/distributions/php-7.4.33.tar.gz

2)解压缩

    tar -zxvf php-7.4.33.tar.gz
    cd php-7.4.33

3)生成编译文件

    ./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74/etc --with-curl --with-freetype --enable-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml --with-openssl --with-external-pcre --with-pear  --with-jpeg --with-xmlrpc --with-xsl --with-zlib --with-openssl --enable-fpm --enable-bcmath --enable-inline-optimization --enable-mbregex --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-mbstring --enable-mysqlnd --with-pdo-mysql=mysqlnd

4)编译安装

    make  && make install

    #成功输出

    Build complete.

    Don't forget to run 'make test'.

    Installing shared extensions:     /usr/local/php74/lib/php/extensions/no-debug-non-zts-20190902/
    Installing PHP CLI binary:        /usr/local/php74/bin/
    Installing PHP CLI man page:      /usr/local/php74/php/man/man1/
    Installing PHP FPM binary:        /usr/local/php74/sbin/
    Installing PHP FPM defconfig:     /usr/local/php74/etc/
    Installing PHP FPM man page:      /usr/local/php74/php/man/man8/
    Installing PHP FPM status page:   /usr/local/php74/php/php/fpm/
    Installing phpdbg binary:         /usr/local/php74/bin/
    Installing phpdbg man page:       /usr/local/php74/php/man/man1/
    Installing PHP CGI binary:        /usr/local/php74/bin/
    Installing PHP CGI man page:      /usr/local/php74/php/man/man1/
    Installing build environment:     /usr/local/php74/lib/php/build/
    Installing header files:          /usr/local/php74/include/php/
    Installing helper programs:       /usr/local/php74/bin/
      program: phpize
      program: php-config
    Installing man pages:             /usr/local/php74/php/man/man1/
      page: phpize.1
      page: php-config.1
    Installing PEAR environment:      /usr/local/php74/lib/php/
    [PEAR] Archive_Tar    - installed: 1.4.14
    [PEAR] Console_Getopt - installed: 1.4.3
    [PEAR] Structures_Graph- installed: 1.1.1
    [PEAR] XML_Util       - installed: 1.4.5
    warning: pear/PEAR dependency package "pear/Archive_Tar" installed version 1.4.14 is not the recommended version 1.4.4
    [PEAR] PEAR           - installed: 1.10.13
    Wrote PEAR system config file at: /usr/local/php74/etc/pear.conf
    You may want to add: /usr/local/php74/lib/php to your php.ini include_path
    /home/bart/php-7.4.33/build/shtool install -c ext/phar/phar.phar /usr/local/php74/bin/phar.phar
    ln -s -f phar.phar /usr/local/php74/bin/phar
    Installing PDO headers:           /usr/local/php74/include/php/ext/pdo/

    /usr/local/php74/bin/php -v

5)安装完成后设置环境变量

    vim /etc/profile

    添加
    PATH=$PATH:/usr/local/php74/bin
    export PATH

    立即生效
    source  /etc/profile

6)复制源码中的配置文件到安装目录

    #我们将配置文件设置在了/usr/local/php74/etc目录下,需要将配置文件拷贝到该目录。

    cp php-7.4.33/php.ini-production /usr/local/php74/etc/php.ini

    cp /usr/local/php74/etc/php-fpm.conf.default /usr/local/php74/etc/php-fpm.conf

    cp /usr/local/php74/etc/php-fpm.d/www.conf.default /usr/local/php74/etc/php-fpm.d/www.conf

7) 注册系统服务

    #当php编译安装完成后,php-fpm还不是系统服务。为了方便使用,将其注册为系统服务。
    #找到 init.d.php-fpm

    [root@aaaaa php-7.4.33]# find / -name init.d.php-fpm
    /opt/php-7.4.33/sapi/fpm/init.d.php-fpm

    #将它拷贝到/etc/init.d目录下
    cp /opt/php-7.4.33/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    #修改权限
    chmod 755 /etc/init.d/php-fpm 或者 chmod +x /etc/init.d/php-fpm

    #php-fpm基本操作

    /etc/init.d/php-fpm start
    或者
    service php-fpm start
    service php-fpm status
    service php-fpm stop

    Usage: /etc/init.d/php-fpm {start|stop|force-quit|restart|reload|status|configtest}

注意:PHP7.4编译安装问题解决及各依赖安装

https://blog.csdn.net/qq_16174727/article/details/120214676

安装oniguruma

    yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-6.9.7.1-1.el7.remi.x86_64.rpm

    yum install http://rpms.remirepo.net/enterprise/7/remi/x86_64/oniguruma5php-devel-6.9.7.1-1.el7.remi.x86_64.rpm

解决 configure: error: Package requirements (libpcre2-8 >= 10.30) were not met:

    # 下载 解压
    wget https://liquidtelecom.dl.sourceforge.net/project/pcre/pcre2/10.35/pcre2-10.35.tar.gz
    tar xzvf pcre2-10.35.tar.gz
    cd pcre2-10.35

    # 生成编译文件
    ./configure --prefix=/usr/local/pcre2 \
    --enable-pcre2-16 \
    --enable-pcre2-32 \
    --enable-jit \
    --enable-jit-sealloc

    # 编译
    make && make install

    #安装完成后设置环境变量
    vim /etc/profile/
    #添加
    export PKG_CONFIG_PATH=/usr/local/pcre2/lib/pkgconfig/
    #立即生效
    source  /etc/profile
Card image cap

每一个你不满意的现在,都有一个你不努力的曾经。