安装必要的依赖

yum install -y epel-release
yun update -y
 
yum install -y autoconf curl-devel openssl openssl-devel openssl openssl-devel gcc gcc-c++ libxml2 libxml2-devel libpng libpng-devel bzip2 bzip2-devel freetype-devel libicu-devel libjpeg-devel

wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
 
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

下载安装

wget https://www.php.net/distributions/php-7.3.13.tar.gz
tar -xzvf php-7.3.13.tar.gz
cd php-php-7.3.13/

wget https://www.php.net/distributions/php-7.2.31.tar.gz
tar -xzvf php-7.2.31.tar.gz
cd php-7.2.31/

编译

./configure --prefix=/usr/local/php7 \
--enable-fpm \
--enable-shared \
--enable-soap \
--enable-bcmath \
--enable-calendar \
--enable-ftp \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--enable-gd-jis-conv \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-pcntl \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-zip \
--enable-mysqlnd-compression-support \
--enable-opcache \
--enable-inline-optimization \
--enable-intl \
--enable-simplexml \
--enable-xmlreader \
--enable-xmlwriter \
--disable-phpdbg \
--disable-phpdbg-webhelper \
--disable-debug \
--disable-rpath \
--with-xmlrpc \
--with-openssl \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--with-iconv \
--with-bz2 \
--with-curl \
--with-cdb \
--with-pcre-dir \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-gettext \
--with-mhash \
--with-libmbfl \
--with-onig \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-pear \
--with-libxml-dir \

make安装

make && make install

环境变量配置以及配置文件拷贝

//加入环境变量中
vi /etc/profile
export PATH=/usr/local/php7/bin:$PATH
source /etc/profile

// 为了防止环境变量设置错误导致无法执行ls等基本命令,处理方案
export PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/X11R6/bin

//配置文件拷贝到指定的目录
php -i | grep php.ini
cp php.ini-development /usr/local/php7/lib/php.ini

配置php-fpm服务

cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
//编辑php-fpm.conf 去掉注释
vim /usr/local/php7/etc/php-fpm.conf
pid = run/php-fpm.pid

//自定义加载配置信息启动
/usr/local/php7/sbin/php-fpm -c /usr/local/php7/lib/php.ini -y /usr/local/php7/etc/php-fpm.conf

重启php-fpm:
# ps -ef | grep php
root     18073     1  0 14:04 ?        00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody   18074 18073  0 14:04 ?        00:00:00 php-fpm: pool www
nobody   18075 18073  0 14:04 ?        00:00:00 php-fpm: pool www
root     18760  3901  0 14:09 pts/0    00:00:00 grep --color=auto php

kill -USR2 18074

pecl方式安装扩展

pecl install redis
echo extension=redis.so >>/usr/local/php7/lib/php.ini

swoole扩展编译安装

git clone https://gitee.com/swoole/swoole.git
cd swoole
phpize

// 预编译配置
./configure \
--enable-coroutine \
--enable-openssl  \
--enable-http2  \
--enable-async-redis \
--enable-sockets \
--enable-mysqlnd
--with-php-config=/usr/local/php7/bin/php-config

//安装
make &&  make install

echo extension=swoole.so >>/usr/local/php7/lib/php.ini

//查看swoole相关信息
php --ri swoole 

Composer安装


wget https://mirrors.aliyun.com/composer/composer.phar

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

//创建一个composer用户
useradd composer
su composer

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

zhiqiang
243 声望14 粉丝