Lnmp环境搭建之php-7.2.19安装配置

==----------------------------------------------------------------------------------------------------------------------

-----== LINUX - PHP7搭建   参考:https://blog.csdn.net/ai_zxc/article/details/84075619   【成功!!!】

1、安装扩展包并更新系统内核
    yum install epel-release -y
    yum update

2、先安装依赖:
    yum -y install php-mcrypt libmcrypt-devel libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libxslt libxslt-devel cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib m4 autoconf gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel wget net-tools zip

3、下载软件包并解压
    下载地址:http://www.php.net/downloads.php
    cd /mine/software/php-7.2.19
    php-7.2.19.tar.bz2文件的解压:
    1、yum -y install bzip2
    2、bzip2 -d php-7.2.19.tar.bz2
    3、tar -xf php-7.2.19.tar

4、进入php-7.2.19,编译
    ./configure --prefix=/mine/serve/php \
    --with-config-file-path=/mine/serve/php/etc \
    --with-curl \
    --with-gd \
    --with-gettext \
    --with-iconv-dir \
    --with-kerberos \
    --with-libdir=lib64 \
    --with-libxml-dir \
    --with-openssl \
    --with-pcre-regex \
    --with-pdo-sqlite \
    --with-pear \
    --with-xmlrpc \
    --with-xsl \
    --with-zlib \
    --enable-fpm \
    --enable-bcmath \
    --enable-libxml \
    --enable-inline-optimization \
    --enable-mbregex \
    --enable-mbstring \
    --enable-opcache \
    --enable-pcntl \
    --enable-shmop \
    --enable-soap \
    --enable-sockets \
    --enable-sysvsem \
    --enable-xml \
    --enable-zip \
    --enable-static \
    --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd \
    --with-freetype-dir \
    --with-jpeg-dir \
    --with-png-dir \
    --disable-debug \
    --disable-fileinfo

    结果:
    +--------------------------------------------------------------------+
    | License:                                                           |
    | This software is subject to the PHP License, available in this     |
    | distribution in the file LICENSE.  By continuing this installation |
    | process, you are bound by the terms of this license agreement.     |
    | If you do not agree with the terms of this license, you must abort |
    | the installation process at this point.                            |
    +--------------------------------------------------------------------+

    Thank you for using PHP.

    config.status: creating php7.spec
    config.status: creating main/build-defs.h
    config.status: creating scripts/phpize
    config.status: creating scripts/man1/phpize.1
    config.status: creating scripts/php-config
    config.status: creating scripts/man1/php-config.1
    config.status: creating sapi/cli/php.1
    config.status: creating sapi/fpm/php-fpm.conf
    config.status: creating sapi/fpm/www.conf
    config.status: creating sapi/fpm/init.d.php-fpm
    config.status: creating sapi/fpm/php-fpm.service
    config.status: creating sapi/fpm/php-fpm.8
    config.status: creating sapi/fpm/status.html
    config.status: creating sapi/phpdbg/phpdbg.1
    config.status: creating sapi/cgi/php-cgi.1
    config.status: creating ext/phar/phar.1
    config.status: creating ext/phar/phar.phar.1
    config.status: creating main/php_config.h
    config.status: executing default commands

5、安装
    make clean && make -j 4 && make install

    注:这里可能要一会,稍微等个三四分钟。可能超过五分钟!

6、查看版本
    cd /mine/serve/php/bin
    ./php -v

7、配置php.ini

    找到php.ini-production:
    find / -name php.ini-production

    复制php.ini-production到PHP安装目录/mine/serve/php:
    cp php.ini-production /mine/serve/php/etc

8、配置php-fpm

    cd  /mine/serve/php/etc
    cp php-fpm.conf.default php-fpm.conf

9、配置www.conf

    cd /mine/serve/php/etc/php-fpm.d
    cp www.conf.default www.conf

10、配置php-fpm.service

    find / -name php-fpm.service

    [root@iZm5eizpokikoertia0x31Z php-fpm.d]# find / -name php-fpm.service
    /mine/software/php-7.2.19/php-7.2.19/sapi/fpm/php-fpm.service

    cd /mine/software/php-7.2.19/php-7.2.19/sapi/

    cp php-fpm.service /usr/lib/systemd/php-fpm.service

11、启动PHP

    /mine/serve/php/sbin/php-fpm
    [root@iZm5eizpokikoertia0x31Z /]# ps -ef | grep php
    root     18370     1  0 Jun14 ?        00:00:01 wget http://cn2.php.net/distributions/php-7.2.19.tar.bz2
    root     20142     1  0 19:33 ?        00:00:00 php-fpm: master process (/mine/serve/php/etc/php-fpm.conf)
    nobody   20143 20142  0 19:33 ?        00:00:00 php-fpm: pool www
    nobody   20144 20142  0 19:33 ?        00:00:00 php-fpm: pool www
    root     20153 22675  0 19:33 pts/1    00:00:00 grep --color=auto php

12、启动php-fpm服务并加入开机自启动

    systemctl enable php-fpm.service
    systemctl restart php-fpm.service




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

Centos7解压.tar.bz2提示tar (child): bzip2: Cannot exec: No such file or directory解决方法

原因是因为该centos没有bzip2解压工具
解决方法如下:
yum -y install bzip2

php-7.2.19.tar.bz2文件的解压:
1、yum -y install bzip2
2、bzip2 -d php-7.2.19.tar.bz2
3、tar -xf php-7.2.19.tar



----------------------------------------------------------------------------------------------------------
1、查看php-fpm是否开启
命令:ps -ef|grep php
结果如果只有两行,可能就是没开启;

2、查看php-fpm的位置
命令:whereis php-fpm
找到php-fpm文件,直接绝对路径就可以做到开启;

3、开启php-fpm
命令:/mine/serve/php/sbin/php-fpm

4、再次输入命令ps -ef|grep php,查看是否已经开启
[root@iZm5eizpokikoertia0x31Z /]# ps -ef | grep php
root     18370     1  0 Jun14 ?        00:00:01 wget http://cn2.php.net/distributions/php-7.2.19.tar.bz2
root     20142     1  0 19:33 ?        00:00:00 php-fpm: master process (/mine/serve/php/etc/php-fpm.conf)
nobody   20143 20142  0 19:33 ?        00:00:00 php-fpm: pool www
nobody   20144 20142  0 19:33 ?        00:00:00 php-fpm: pool www
root     20153 22675  0 19:33 pts/1    00:00:00 grep --color=auto php
这是已经开启了。

----------------------------------------------------------------------------------------------------------------------==
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值