REMI源安装php7.3
参考:https://blog.csdn.net/Phplayers/article/details/100901352
php5.6安装参考:https://www.cnblogs.com/EasonJim/p/9614577.html
注意:记得去掉--enablerepo=remi,直接使用--enablerepo=remi-php56
一、yum 安装 PHP7.3
1、首先安装 EPEL 源:
yum install epel-release -y
# Extra Packages for Enterprise Linux 。EPEL是一个比官方rpm包更丰富、版本相对更高的额外第三方源。
2、安装 REMI 源:
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
# 除了EPEL源之外还有REMI的源。它包含最新版本 PHP 和 MySQL 包
3、安装 Yum 源管理工具:
yum install yum-utils -y
# 维护YUM并提高其性能的工具
4、安装php73:
yum --enablerepo=remi-php73 install php -y # yum --enablerepo=remi-php73 install php73 -y
# yum --enablerepo=[repo] 启用一个或多个软件源(支持通配符)
5、安装常用扩展:
yum --enablerepo=remi-php73 install php-gmp php-zip php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt php-devel php-mysql php-gd php-bcmath php-pdo php-pecl-imagick php-fpm php-curl php-devel php-pear -y
# 卸载命令:yum --enablerepo=remi-php73 remove xxx xxx ..
安装mongodb扩展:
yum --enablerepo=remi-php73 install php-devel php-pear -y pecl install mongodb
6、开启php:
systemctl start php-fpm
7、加入开机自启动
systemctl enable php-fpm
8、查看php版本:
php -v
二、编译安装 swoole 扩展
1、下载:
去https://pecl.php.net/package/swoole下载最新的swoole包。
wget -c https://pecl.php.net/get/swoole-4.4.15.tgz
# git下载地址:https://github.com/swoole/swoole-src
git clone https://github.com/swoole/swoole-src.git
2、解压到指定目录:
tar xf swoole-4.4.15.tgz
3、进入该目录:
cd swoole-4.4.15
4、使用 phpize 生成 configure
/usr/bin/phpize
# phpize 可以直接扩展 php 模块,无需重新编译php
5、编译配置
./configure --enable-openssl --with-php-config=/usr/bin/php-config
# ./configure 后面可以指定的是 php-config 文件的路径,不知道路径可以 find 出来
6、编译 && 安装:
make && make install
7、编译安装成功后,修改php.ini
加入:
# vim /etc/php.ini extension=swoole.so
8、记得重启php-fmp:
systemctl restart php-fpm
9、查看是否启用安装成功:
php --ri swoole
# 注意是否支持ssl
三、安装composer
1、下载安装
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" php composer-setup.php
如果上述方式下载不行,可以尝试下面这种方式:
curl -sS https://getcomposer.org/installer | php
2、移动 composer.phar,这样 composer 就可以进行全局调用:
mv composer.phar /usr/local/bin/composer
3、切换为国内镜像:
# composer config -g repo.packagist composer https://packagist.phpcomposer.com # 可以切换的镜像源 composer repo:ls -- --------------- ------------------------------------------------ composer https://packagist.org phpcomposer https://packagist.phpcomposer.com aliyun https://mirrors.aliyun.com/composer tencent https://mirrors.cloud.tencent.com/composer huawei https://mirrors.huaweicloud.com/repository/php laravel-china https://packagist.laravel-china.org cnpkg https://php.cnpkg.org sjtug https://packagist.mirrors.sjtug.sjtu.edu.cn -- --------------- ------------------------------------------------
4、composer自我更新
composer selfupdate
四、Dockerfile
1、dockerfile-php-fpm-init
# This is my first easyswoole init Dockerfile # Version 1.0 FROM centos:7 MAINTAINER doublexi "shuangxi.wang@lgitt.com" # 定义swoole版本 ENV SWOOLE_VERSION 4.4.15 RUN yum install epel-release -y \ && useradd www -M -s /sbin/nologin \ && yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y \ && yum install yum-utils -y \ && yum --enablerepo=remi-php73 install php -y \ && yum --enablerepo=remi-php73 install php-gmp php-zip php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt php-devel php-mysql php-gd php-bcmath php-pdo php-pecl-imagick php-fpm -y \ && yum clean all \ && yum install make -y \ && curl -fSL https://pecl.php.net/get/swoole-${SWOOLE_VERSION}.tgz -o /opt/swoole-${SWOOLE_VERSION}.tgz \ && tar xf /opt/swoole-${SWOOLE_VERSION}.tgz -C /opt/ \ && cd /opt/swoole-${SWOOLE_VERSION} \ && /usr/bin/phpize \ && ./configure --enable-openssl --with-php-config=/usr/bin/php-config \ && make && make install \ && make clean \ && php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \ && php composer-setup.php \ && mv composer.phar /usr/local/bin/composer \ && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer \ && cd /opt && rm -rf swoole-${SWOOLE_VERSION}* \ && echo "set encoding=utf-8" >>/root/.vimrc COPY php.ini /etc/php.ini COPY php-fpm.conf /etc/php-fpm.conf COPY www.conf /etc/php-fpm.d/www.conf COPY localtime /etc/localtime EXPOSE 9000 CMD ["/usr/sbin/php-fpm", "--nodaemonize"]
2、dockerfile-easyswoole-init
# This is my first easyswoole init Dockerfile # Version 1.0 FROM centos:7 MAINTAINER doublexi "shuangxi.wang@lgitt.com" # 定义swoole版本 ENV SWOOLE_VERSION 4.4.15 RUN yum install epel-release -y \ && useradd www -M -s /sbin/nologin \ && yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y \ && yum install yum-utils -y \ && yum --enablerepo=remi-php73 install php -y \ && yum --enablerepo=remi-php73 install php-gmp php-zip php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt php-devel php-mysql php-gd php-bcmath php-pdo php-pecl-imagick php-fpm -y \ && yum clean all \ && yum install make -y \ && curl -fSL https://pecl.php.net/get/swoole-${SWOOLE_VERSION}.tgz -o /opt/swoole-${SWOOLE_VERSION}.tgz \ && tar xf /opt/swoole-${SWOOLE_VERSION}.tgz -C /opt/ \ && cd /opt/swoole-${SWOOLE_VERSION} \ && /usr/bin/phpize \ && ./configure --enable-openssl --with-php-config=/usr/bin/php-config \ && make && make install \ && make clean \ && php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \ && php composer-setup.php \ && mv composer.phar /usr/local/bin/composer \ && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer \ && cd /opt && rm -rf swoole-${SWOOLE_VERSION}* \ && echo "set encoding=utf-8" >>/root/.vimrc COPY php.ini /etc/php.ini COPY php-fpm.conf /etc/php-fpm.conf COPY www.conf /etc/php-fpm.d/www.conf COPY localtime /etc/localtime RUN mkdir /opt/easyswoole \ && cd /opt/easyswoole \ && composer require easyswoole/easyswoole=3.x \ && php vendor/easyswoole/easyswoole/bin/easyswoole install \ && chown -R www.www ./ WORKDIR /opt/easyswoole EXPOSE 9501 CMD ["php", "easyswoole", "start"]