编译php7.3.6

作者: 钾肥尔德 | 来源:发表于2019-07-04 14:36 被阅读0次

    依赖

    yum install autoconf kernel-devel libtool openssl-devel libcurl-devel libxml2-devel readline-devel libzip-devel zlib-devel
    

    安装Cmake

    wget https://github.com/Kitware/CMake/releases/download/v3.15.0-rc3/cmake-3.15.0-rc3.tar.gz
    tar -xzf cmake-3.15.0-rc3.tar.gz
    ./bootstrap --prefix=/usr/local/cmake
    gmake
    make && make install
    

    安装libzip 1.5.2

    wget https://libzip.org/download/libzip-1.5.2.tar.gz
    tar -xzf libzip-1.5.2.tar.gz
    cmake .
    make
    make install
    

    编译php

    ./configure --prefix=/usr/local/php7 --enable-mysqlnd --with-pdo-mysql --with-pdo-mysql=mysqlnd --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --enable-mbstring --enable-phpdbg --enable-shmop --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-zip --with-libzip=/usr/lib64 --with-zlib --with-curl --with-pear --with-openssl --enable-pcntl --with-readline --with-apxs2
    
    #要加 --with-apxs2 才会生成libphp7.so
    
    make
    make install
    
    cp php.ini-development /usr/local/php-latest/lib/
    cd /usr/local/php-latest/etc
    mv php-fpm.conf.default php-fpm.conf
    mv php-fpm.d/www.conf.default php-fpm.d/www.conf
    

    create symbolic links for your for your binary files

    cd /usr/local
    ln -s php-latest/bin/php php
    ln -s php-latest/bin/php-cgi php-cgi
    ln -s php-latest/bin/php-config php-config
    ln -s php-latest/bin/phpize phpize
    ln -s php-latest/bin/phar.phar phar
    ln -s php-latest/bin/pear pear
    ln -s php-latest/bin/phpdbg phpdbg
    ln -s php-latest/sbin/php-fpm php-fpm
    

    启动PHP-FPM

    /usr/local/php-latest/sbin/php-fpm
    

    配置文件。在php的编译目录,执行以下命令。

    cp php.ini-development /usr/local/php7/lib/php.ini
    

    查看apache的配置文件是否已经开启关联(一般情况下,安装完php后,会开启,假如没有开启则开启)

    vim /usr/local/apache/conf/httpd.conf
    LoadModule php5_module /usr/lib64/httpd/modules/libphp7.so
    

    加入以下代码:

    <FilesMatch \.php$>SetHandler application/x-httpd-php</FilesMatch>
    

    更改以下代码:

    DirectoryIndex index.html index.shtml index.cgi index.php index.phtml index.php3
    

    找到AddType处,并添加以下2行:

    AddType application/x-httpd-php .php .php3 .phtml .inc
    AddType application/x-httpd-php-source .phps
    

    编译PHP时出现的提示,报错信息为: configure: error: off_t undefined; check your library configuration

    vim /etc/ld.so.conf
    添加
    /usr/local/lib64
    /usr/local/lib
    /usr/lib
    /usr/lib64
    :wq
    
    ldconfig -v
    

    编译php7可能遇到的问题之一是无法生成libphp7.so文件,这可以做以下检查:

    1.检查configure是不是缺少一个 --with-apxs2 ,添加一下
    2.然后确认apache配置文件httpd.conf中是否含有以下配置:

    <FilesMatch .php$>
    SetHandler application/x-httpd-php
    </FilesMatch>
    

    如果有,则进行第3步,不然添加一下
    3.重新 ./configure + 参数 make make install,重新安装安装一下,记得加--with-apxs2。

    相关文章

      网友评论

        本文标题:编译php7.3.6

        本文链接:https://www.haomeiwen.com/subject/gwzlhctx.html