linux centos 下docker php7.3环境安装配置(yum 源安装php7.3),以及redis,swoole,ssh2,amqp等扩展安装

23 篇文章 1 订阅
9 篇文章 0 订阅

一、安装centos容器


1、下载centos镜像

docker pull centos

2、启动容器(linux中代码存放路径:/www     docker容器中代码存放的路径 /home)

docker run --restart=always -p 86:86 -d -e "container=docker" --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup -v /www/website:/home/www --name centos centos /usr/sbin/init

3、进入容器 (容器名称centos)

docker exec -it centos /bin/bash

如果服务器试代理上网的,需要执行如下代码,才可以正常下载。

export http_proxy=http://自己的代理上网地址 && export https_proxy=http://自己的代理上网地址

二、NGINX 安装(配置文件/etc/nginx)


1、添加nginx的源

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2、安装nginx

yum install -y nginx

3、启动

#开机自动启动nginx服务
systemctl enable nginx
#启动nginx服务
systemctl start nginx

如果提示:Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

意思是:会在/etc/systemd/system/multi-user.target.wants/目录下生成nginx.service的软链接这样就可以再次执行

systemctl enable nginx.service。

其他命令

# 启动nginx服务
systemctl start nginx

# 重启nginx服务
systemctl restart nginx

# 停止nginx服务
systemctl stop nginx

# 查看nginx服务
systemctl status nginx

# 开机自动启动nginx服务
systemctl enable nginx

# 禁止开机启动nginx服务
systemctl disable nginx

# 查询是否开机启动redis服务
systemctl is-enable nginx

# 重新加载nginx服务,修改配置文件后使用这个
systemctl reload nginx  

4、配置文件:
以下是Nginx的默认路径:
(1) Nginx配置路径:/etc/nginx/
(2) PID目录:/var/run/nginx.pid
(3) 错误日志:/var/log/nginx/error.log
(4) 访问日志:/var/log/nginx/access.log
(5) 默认站点目录:/usr/share/nginx/html

5、修改配置文件(修改配置文件后需要重启:systemctl restart nginx)

server {
    listen       86;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /home/www;
        # 修改1:这里新增了index.php
        index index.php index.html index.htm;
        # 修改2:这里新增url重写(path)
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        root         /home/www;
        #默认就使用php-fpm
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #修改4:修改fastcig的路径
        fastcgi_param  SCRIPT_FILENAME  /home/www$fastcgi_script_name;
        include        fastcgi_params;
    }
}

三、yum安装php7.3

1、安装EPEL:

yum install epel-release

2、安装remi:

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

3、安装PHP 7.3 

yum --enablerepo=remi-php73 install php

4、查找扩展包(获取自己需要的扩展信息)

yum --enablerepo=remi-php73 search php | grep php73

执行后出现如下信息:

[root@ff5c6fb00c84 /]# yum --enablerepo=remi-php73 search php | grep php73
 * remi-php73: mirror.23media.com
php73.x86_64 : Package that installs PHP 7.3
php73-php.x86_64 : PHP scripting language for creating dynamic web sites
php73-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
php73-php-brotli.x86_64 : Brotli Extension for PHP
php73-php-cli.x86_64 : Command-line interface for PHP
php73-php-common.x86_64 : Common files for PHP
php73-php-componere.x86_64 : Composing PHP classes at runtime
php73-php-dba.x86_64 : A database abstraction layer module for PHP applications
php73-php-dbg.x86_64 : The interactive PHP debugger
php73-php-devel.x86_64 : Files needed for building PHP extensions
php73-php-embedded.x86_64 : PHP library for embedding in applications
php73-php-enchant.x86_64 : Enchant spelling extension for PHP applications
php73-php-fpm.x86_64 : PHP FastCGI Process Manager
php73-php-gd.x86_64 : A module for PHP applications for using the gd graphics
php73-php-geos.x86_64 : PHP module for GEOS
php73-php-gmp.x86_64 : A module for PHP applications for using the GNU MP
php73-php-imap.x86_64 : A module for PHP applications that use IMAP
php73-php-interbase.x86_64 : A module for PHP applications that use
php73-php-intl.x86_64 : Internationalization extension for PHP applications
php73-php-json.x86_64 : JavaScript Object Notation extension for PHP
。
。
。

5、安装php扩展(从上步骤中获取可安装的扩展名称,例:php73-php-gd.x86_64,最终:yum --enablerepo=remi-php73 install -y php-gd)

yum --enablerepo=remi-php73 install -y php-pecl-swoole4 php-pecl-amqp php-pecl-ssh2 php-fpm php-cli php-bcmath php-gd php-json php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-pecl-crypto php-pecl-mcrypt php-pecl-geoip php-recode php-snmp php-soap php-xml php-xmlrpc php-pecl-redis5

6、查看php已安装的扩展

php -m

执行后出现如下信息(还是以gd为例,在列表中发现有gd,说明扩展已成功安装):

[root@ff5c6fb00c84 /]# php -m
[PHP Modules]
amqp
bcmath
bz2
calendar
Core
crypto
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
geoip
gettext
。
。
。

7、添加开机启动

systemctl enable php-fpm

8、 禁止开机启动redis服务

systemctl disable php-fpm

9、其他命令 

systemctl start php-fpm    #启动
systemctl stop php-fpm     #停止
systemctl restart php-fpm  #重启

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值