编译安装php7.0

注:安装前必须先安装MySQL,apache服务器需要先安装apache

contos下编译安装php7.0

1,下载软件

php7.0下载地址: https://www.php.net/distributions/php-7.0.11.tar.gz

2,安装php扩展依赖

        yum install -y epel-release
        yum install -y openssl openssl-devel curl-devel libpng libpng-devel libxslt libxslt-devel bzip2 bzip2-devel libmcrypt-devel openssl openssl-devel curl-devel

3,解压安装包

        tar -zxvf php-7.0.11.tar.gz

4,编译安装

     cd php-7.0.10
    ./configure --prefix=/usr/local/server/php7.0 \
    --with-config-file-path=/usr/local/server/php7.0 \
    --with-apxs2=/usr/local/server/apache2.4.4/bin/apxs \
    --enable-fpm \
    --with-gd \
    --enable-bcmath \
    --with-gettext \
    --enable-inline-optimization \
    --enable-sockets \
    --enable-mbstring \
    --enable-sysvshm \
    --enable-sysvsem \
    --enable-sysvmsg \
    --with-zlib \
    --with-mcrypt \
    --with-bz2 \
    --with-xsl \
    --with-pdo-mysql \
    --with-pdo-sqlite \
    --with-mysqli \
    --with-openssl \
    --with-mhash \
    --enable-exif \
    --enable-gd-native-ttf \
    --enable-shmop \
    --enable-soap \
    --enable-mbregex \
     --with-kerberos \
    --with-libdir=lib64 \
    --enable-mbregex \
    --enable-opcache \
    --with-xmlrpc
注释:
  ./configure --prefix=php安装位置\
  --with-config-file-path=php配置文件路径 \
  --with-apxs2=mysql安装路目录下/bin/apxs \
make编译
  make && make install

5,配置

    1、复制配置文件
        cp php.ini-development /usr/local/server/php7.0/php.ini
        cp /usr/local/server/php7.0/etc/php-fpm.conf.default  /usr/local/server/php7.0/etc/php-fpm.conf
        cp /usr/local/server/php7.0/etc/php-fpm.d/www.conf.default  /usr/local/server/php7.0/etc/php-fpm.d/www.conf
    2、创建软连接便于使用
        ln -s /usr/local/server/php7.0/bin/php /usr/local/bin/php
         ln -s /usr/local/server/php7.0/sbin/php-fpm /usr/local/bin/php-fpm
    3、创建启动方式
        创建php-fpm.service
           vim /usr/lib/systemd/system/php-fpm.service
        添加如下内容
            [Unit]
             Description=php-fpm
             After=network.target
             [Service]
             Type=forking
             ExecStart=/usr/local/server/php7.0/sbin/php-fpm
             ExecReload=/usr/local/server/php7.0/sbin/php-fpm -s reload
             ExecStop=/usr/local/server/php7.0/sbin/php-fpm -s stop
             PrivateTmp=true
             [Install]
             WantedBy=multi-user.target
        使文件生效
            systemctl daemon-reload
        启动/停止/重启
            systemctl start php-fpm
            systemctl stop php-fpm
            systemctl restart php-fpm
    4、开启启动
        systemctl enable php-fpm

你可能感兴趣的:(编译安装php7.0)