LAMP-PHP7安装、配置、环境变量、启动及关闭

    xiaoxiao2022-07-04  127

    首先先安装一些依赖包 yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel openssl openssl-devel 下载PHP http://mirrors.sohu.com/php/

    开始安装 cd /usr/local/phpall

    #解压 tar -zxvf php-7.1.11.tar.gz

    #进入源码包目录 cd php-7.1.11

    #配置编译参数 ./configure –prefix=/usr/local/php7/ –with-apxs2=/usr/local/apache/bin/apxs –enable-mbstring –with-curl –with-gd –enable-fpm –enable-mysqlnd –with-pdo-mysql=mysqlnd –with-config-file-path=/usr/local/php7/etc/ –with-mysqli=mysqlnd

    #安装 make && make install

    开启设置php7的配置文件php.ini、php-fpm.conf、www.conf 和php-fpm脚本

    #直接使用编译后未经优化处理的配置 1、把php安装包中的php.ini-production拷贝到/usr/local/php7/etc/php.ini cp php.ini-production /usr/local/php7/etc/php.ini

    2、配置php-fpm.conf,这是php-fpm配置文件: cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

    3、配置www.conf,配置用户的文件 cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

    4、将php-fpm启动文件复制到init.d文件夹中一份方便启动 cp -R /usr/local/php7/sbin/php-fpm /etc/init.d/php-fpm

    添加php的环境变量 echo -e ‘\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n’ >> /etc/profile source /etc/profile

    测试PHP的配置文件是否正确合法 php-fpm -t

    [root@localhost /]# php-fpm -t [23-Apr-2019 04:36:54] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful

    启动php /etc/init.d/php-fpm 然后按enter键启动

    [root@localhost /]# /etc/init.d/php-fpm

    关闭php pkill php-fpm 查看php7版本信息

    [root@localhost /]# php -v PHP 7.1.11 (cli) (built: Apr 23 2019 03:32:32) ( ZTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    最新回复(0)