centos 安装php7.4,搭建hyperf,转发RDS

安装php7.4,搭建hyperf

    8  sudo yum install -y epel-release
    9  sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
   10  sudo yum -y install yum-utils
   11  sudo yum-config-manager --enable remi-php74
   12  sudo yum install -y php  php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis php74-php-pecl-swoole4
   13  php -v
   14  php --ri swoole
   16  yum install wget
   17  cd /home
   18  mkdir temp
   19  cd temp
   20  wget https://github.com/swoole/swoole-src/archive/refs/tags/v4.5.11.tar.gz
   21  tar -zxvf v4.5.11.tar.gz
   22  cd swoole-src-4.5.11/
   23  phpize
   24  openssl version
   26  ./configure 
   27  make
   28  make install
   30  yum install -y vim
   31  vim /etc/php.ini
   //php配置中添加swoole
   extension="swoole.so"
   swoole.use_shortname = 'Off'
   32  php --ri swoole
   33  yum install -y lrzsz
   34  yum -y install docker
   35  systemctl start docker
   36  docker -v
   37 yun install -y nginx 
	//需要的话安所nginx steam模块
	38 yum install -y nginx-all-modules

有时RDS不请允许本地所在区域登录,就在服务器做个中转
安装nignx,做端口数据转发
在nginx.conf最后面加上

stream{
        include /etc/nginx/conf.d/*.stream;
}

在conf.d里创建一个mysql.stream的文件

	upstream tcpLink {
		hash $remote_addr consistent;
		server database-1.cr.ap-southeast-1.rds.amazonaws.com:3306 weight=5 max_fails=3 		fail_timeout=30s;
	}
	server {
		listen 8087;
		proxy_connect_timeout 1s;
		proxy_timeout 3s;
		proxy_pass tcpLink;
	}

运行nginx后会报错:

nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:84

需要安装stream模块
在这比较懒,直接全装了

yum install -y nginx-all-modules

hyperf项目装好后,用docker运行

docker build -t admin-api:1.0.1 .

docker run --rm -p 9501:9501 -d --name admin-api admin-api:1.0.1 


//进入docker

docker exec -it admin-api /bin/bash

记录几个docker命令
docker ps 列出当前运行的image

CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                    NAMES
5135a12fc06c        admin-api:1.0.1    "php /opt/www/bin/..."   17 hours ago        Up 17 hours         0.0.0.0:9501->9501/tcp   admin-api

docker stop 513 根据上面CONTAINER ID,停止

centos7启动php:
重启:systemctl restart php-fpm.service
开启:systemctl start php-fpm.service
关闭:systemctl stop php-fpm.service

你可能感兴趣的:(linux,php,centos,php,linux)