• (OK) centos7 编译 php-5.6.14


    ------------------------------//centos7 编译 php-5.6.14
    //centos7 yum 源
    # yum localinstall http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm -y

    # yum install -y libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel


    [root@localhost php-5.6.14]# pwd
    /opt/project/php-5.6.14
    [root@localhost php-5.6.14]# make clean
    [root@localhost php-5.6.14]# ./buildconf --force

    #####安装编译php56时需要的依赖包
    yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

    ##### install all of the required packages
    yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel

    #####php56编译参数的配置
    ./configure --prefix=/usr/local/php56 --with-config-file-path=/etc --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-curl --with-mcrypt --enable-soap --with-mhash --with-ldap --with-ldap-sasl --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-openssl --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=/usr --with-gettext=/usr --with-zlib=/usr --with-bz2=/usr --with-recode=/usr --with-mysqli=/usr/bin/mysql_config --with-apxs2

    ++++++++++++下面命令不用
    ./configure --with-apxs2=/usr/bin/apxs --with-config-file-path=/etc --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-cli --enable-shared --with-libxml-dir --enable-xml --with-gd --enable-gd-native-ttf --with-openssl --enable-mbstring --with-mcrypt --enable-soap --with-mhash --with-ldap --with-ldap-sasl --enable-opcache --enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-zip --with-zlib --with-zlib-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --with-curl --without-pdo-sqlite --with-sqlite3 --enable-pcntl --enable-calendar --enable-bcmath --enable-exif --enable-ftp --enable-intl --with-bz2 --with-pcre-regex --with-iconv-dir --disable-rpath --enable-shmop --enable-sysvsem --enable-sysvshm --enable-inline-optimization --enable-mbregex --enable-sockets --with-xmlrpc --with-xsl --with-gettext --enable-session --enable-ctype --with-kerberos

    #######新建php用户和php组
    groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php56 -M php

    make -j4 && make install


    #####php56编译参数的配置  这个命令不用
    ./configure --prefix=/usr/local/php56 --exec-prefix=/usr/local/php56 --bindir=/usr/local/php56/bin --sbindir=/usr/local/php56/sbin --includedir=/usr/local/php56/include --libdir=/usr/local/php56/lib/php --mandir=/usr/local/php56/php/man --with-config-file-path=/usr/local/php56/etc --with-mysql-sock=/tmp/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=apache --with-fpm-group=apache --without-gdbm --disable-fileinfo  


    [root@localhost php-5.6.14]# make install
    --------------------------
    Installing PHP SAPI module:       apache2handler
    /usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp5.la /usr/lib64/httpd/modules
    /usr/lib64/apr-1/build/libtool --mode=install install libphp5.la /usr/lib64/httpd/modules/
    libtool: install: install .libs/libphp5.so /usr/lib64/httpd/modules/libphp5.so
    libtool: install: install .libs/libphp5.lai /usr/lib64/httpd/modules/libphp5.la
    libtool: install: warning: remember to run `libtool --finish /opt/project/php-5.6.14/libs'
    chmod 755 /usr/lib64/httpd/modules/libphp5.so
    [activating module `php5' in /etc/httpd/conf/httpd.conf]
    Installing shared extensions:     /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/
    Installing PHP CLI binary:        /usr/local/php56/bin/
    Installing PHP CLI man page:      /usr/local/php56/php/man/man1/
    Installing PHP CGI binary:        /usr/local/php56/bin/
    Installing PHP CGI man page:      /usr/local/php56/php/man/man1/
    Installing build environment:     /usr/local/php56/lib/php/build/
    Installing header files:          /usr/local/php56/include/php/
    Installing helper programs:       /usr/local/php56/bin/
      program: phpize
      program: php-config
    Installing man pages:             /usr/local/php56/php/man/man1/
      page: phpize.1
      page: php-config.1
    Installing PEAR environment:      /usr/local/php56/lib/php/
    [PEAR] Archive_Tar    - already installed: 1.3.12
    [PEAR] Console_Getopt - already installed: 1.3.1
    [PEAR] Structures_Graph- already installed: 1.0.4
    [PEAR] XML_Util       - already installed: 1.2.3
    [PEAR] PEAR           - already installed: 1.9.5
    Wrote PEAR system config file at: /usr/local/php56/etc/pear.conf
    You may want to add: /usr/local/php56/lib/php to your php.ini include_path
    /opt/project/php-5.6.14/build/shtool install -c ext/phar/phar.phar /usr/local/php56/bin
    ln -s -f phar.phar /usr/local/php56/bin/phar
    Installing PDO headers:          /usr/local/php56/include/php/ext/pdo/
    --------------------------

    /usr/bin/cp php.ini-production /usr/local/php56/etc/php.ini
    /usr/bin/cp php.ini-production /etc/php.ini
    /usr/bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
    /usr/bin/cp /usr/local/php56/etc/php-fpm.conf.default /usr/local/php56/etc/php-fpm.conf
    /usr/bin/cp /usr/local/php56/etc/php-fpm.d/www.conf.default /usr/local/php56/etc/php-fpm.d/www.conf
    echo -e ' export PATH=/usr/local/php56/bin:/usr/local/php56/sbin:$PATH ' >> /etc/profile && source /etc/profile
    mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R apache:apache php-fpm
    mkdir -p /var/lib/php/session
    chown -R apache:apache /var/lib/php/

    chmod +x /etc/init.d/php-fpm
    chkconfig --add php-fpm
    chkconfig php-fpm on
    php-fpm -t
    service php-fpm start

    通过命令ps -aux|grep php查看是否成功(图中的php-fpm进程数和进程用户apache都是由www.conf中pm.start_servers和user的值分别决定的)
    可以通过命令php -v查看当前PHP版本信息,图中可以看到当前php56还使用了Zend OPcache缓存,是因为在php.ini文件中添加了zend_extension=opcache.so配置。

    # gedit /etc/php.ini      修改内容如下:
    ---------------
    ;extension=pdo_mysql.so
    ;extension=mysqli.so
    ;extension=mysql.so

    mysqli.default_socket =/var/lib/mysql/mysql.sock
    pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
    short_open_tag = On
    zend_extension=opcache.so
    ---------------

    # gedit /etc/httpd/conf/httpd.conf      修改内容如下:
    ---------------
    LoadModule php5_module        /usr/lib64/httpd/modules/libphp5.so
    FilesMatch .php$>
    SetHandler application/x-httpd-php
    /FilesMatch>

    ---------------

    php -v
    php --ini

    ------------
    MariaDB [(none)]> STATUS;
    UNIX socket:        /var/lib/mysql/mysql.sock
    ------------

    # cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/pdo_mysql.so /usr/lib64/
    # cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/mysqli.so /usr/lib64/

    # systemctl restart mariadb
    # systemctl restart httpd

    # php /var/www/html/index.php

    # gedit /var/www/html/index.php

    --------------------------------
    ?php
    /*** mysql hostname ***/
    $hostname = 'localhost';

    /*** mysql username ***/
    $DBusername = 'root';

    /*** mysql password ***/
    $DBpassword = '123456';

    try {
        $dbh = new PDO("mysql:host=$hostname;dbname=mysql", $DBusername, $DBpassword);
        /*** echo a message saying we have connected ***/
        echo 'Connected to database';
        }
    catch(PDOException $e)
        {
        echo $e->getMessage();
        }
    ?>
    --------------------------------
    ---------------
    [root@localhost html]# /usr/local/bin/php -v
    PHP 5.6.14 (cli) (built: Oct 25 2015 09:29:49)
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    [root@localhost html]# /usr/bin/php
    php      php-cgi  phpize   
    [root@localhost html]# /usr/local/bin/php
    php         php-cgi     php-config  phpize      
    [root@localhost html]# /usr/local/bin/php -v
    PHP 5.6.14 (cli) (built: Oct 25 2015 09:29:49)
    Copyright (c) 1997-2015 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies

    删除老版本: rm /usr/bin/php*
    ---------------

    [root@localhost html]# php --ini
    Configuration File (php.ini) Path: /etc
    Loaded Configuration File:         /etc/php.ini
    Scan for additional .ini files in: (none)
    Additional .ini files parsed:      (none)
    [root@localhost html]#
    ---------------

    具体过程见:  http://blog.chinaunix.net/uid-14735472-id-5271293.html

    ---------------------------下面杂项没用
    #LD_LIBRARY_PATH=/usr/local/lib ./configure
    cp php.ini-production /usr/local/lib/php.ini
    # 设置php-fpm开机自动启动
    chmod +x /etc/init.d/php-fpm
    chkconfig php-fpm on
    cp /data/soft/php/etc/php-fpm.conf.default /data/soft/php/etc/php-fpm.conf
    service php-fpm start
    ./configure --prefix=/usr/local/php/v70 --with-config-file-path=/usr/local/php/v70/etc --with-mysqli=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql
    --with-libdir=/lib/
    --with-ldap=/usr/
    --with-libxml-dir=/usr
    --with-zlib-dir=/usr/lib
    --with-iconv-dir=/usr/local/
    ./configure --prefix=/data/soft/php
     --with-libdir=lib64
     --enable-fpm
     --with-fpm-user=php-fpm
     --with-fpm-group=www
       --with-png-dir=/usr/lib
     --with-jpeg-dir=/usr/lib
     --with-gettext
      --enable-fpm
     ---------------------------

    ---------------------------------------//centos 编译 php
  • 相关阅读:
    Cypress系列(74)- each() 命令详解
    Cypress系列(73)- within() 命令详解
    实战-电力窃露漏电用户自动识别
    谷歌colab切换使用tensorflow1.x版本
    解决pip安装tensorflow下载缓慢问题
    如何将tensorflow1.x代码改写为pytorch代码(以图注意力网络(GAT)为例)
    graph attention network(ICLR2018)官方代码详解(tensorflow)-稀疏矩阵版
    graph attention network(ICLR2018)官方代码详解(tensorflow)
    DGL中文文档
    graphSAGE的python实现
  • 原文地址:https://www.cnblogs.com/ztguang/p/12647061.html
Copyright © 2020-2023  润新知