美文网首页
PHP: 安装php

PHP: 安装php

作者: pingink | 来源:发表于2017-04-27 10:43 被阅读0次

    1. 环境准备

    yum -y update
    yum -y groupinstall "Development tools"
    yum -y install php-gd
    yum -y install freetype*
    yum -y install gd
    yum -y install gd-devel
    yum -y install libmcrypt
    yum -y install libmcrypt-devel
    yum -y install freetype
    yum -y install freetype-devel
    yum -y install libtool-ltdl
    yum -y install libtool-ltdl-devel
    yum -y install libjpeg-devel
    yum -y install libpng-devel
    yum -y install libmcrypt
    yum -y install libmcrypt-devel
    yum -y install libxml2
    yum -y install libxml2-devel
    yum -y install curl-devel
    yum -y install systemd-devel
    yum -y install mysql-server mysql mysql-devel
    

    2. 下载安装包并解压

    wget http://jp2.php.net/distributions/php-7.0.13.tar.gz
    tar -zxvf php-7.0.13.tar.gz
    cd php-7.0.13
    

    3. 编译安装

    ./configure \
    --prefix=/opt/www/php7 \
    --with-config-file-path=/opt/www/php7/etc \
    --with-fpm-user=php \
    --with-fpm-group=php \
    --enable-pcntl \
    --enable-fpm \
    --enable-gd-native-ttf \
    --enable-bcmath \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --enable-soap \
    --enable-opcache \
    --enable-mysqlnd \
    --enable-exif \
    --enable-sockets \
    --enable-mbstring \
    --enable-zip \
    --disable-ipv6 \
    --disable-cgi \
    --with-gd \
    --with-freetype-dir \
    --with-jpeg-dir \
    --with-png-dir \
    --with-openssl \
    --with-zlib \
    --with-mhash \
    --with-curl \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd
    
    make && make install
    

    4. 配置

    cp /opt/www/php7/etc/php-fpm.conf.default /opt/www/php7/etc/php-fpm.conf
    cp /opt/www/php7/etc/php-fpm.d/ww.conf.default /opt/www/php7/etc/php-fpm.d/www.conf
    cp php.ini-production /opt/www/php7/etc/php.ini
    cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm
    

    5. 加入系统启动项

    chkconfig php-fpm on
    

    6. 启动服务

    chmod u+x php7-fpm
    
    #centos6
    service php7-fpm start
    
    #centos7
    service php7-fpm start
    systemctl restart  php-fpm.service
    

    7.1. 扩展安装:phpize

    a. 进入php源码包下的ext,进入扩展包文件
    b. mv config0.m4 config.m4
    c. /opt/www/php7/bin/phpize
    d. ./configure --with-openssl --with-php-config=/opt/www/php7/bin/php-config
    e. make && make install
    f. php.ini 增加 extension=openssl.so
    g. 重启php-fpm
    

    7.2. 扩展安装:pecl

    pecl install {package}
    

    8. 启动参数

    -c 参数指定要加载的php.ini 
    -y 参数指定php-fpm.conf,启用不同的监听端口
    

    相关文章

      网友评论

          本文标题:PHP: 安装php

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