项目技术栈
- hyperf
- vant
环境需要
- PHP7.4 ( redis.so + swoole.so)
- COMPOSER
- DOCKER ( mysql8.0 + redis:latest + rabbitmq:latest + nginx)
- REDIS-CLI
安装过程
- 安装PHP
PHP安装文档
题外话:安装redis和swoole扩展直接用pecl安装就好,常用的pecl,phpize都在usr/bin目录可以直接用 - 安装 docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
安装composer
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php
- php -r "unlink('composer-setup.php');"
- mv composer.phar /usr/local/bin/composer
安装mysql8.0 + redis:latest + rabbitmq:latest + nginx
- mysql
- docker pull mysql:latest
- docker run -dit --name mysql8 --restart always -v /mnt/mysql:/var/lib/mysql -e MYSQL_USER="mushroom" -e MYSQL_PASSWORD="password" -e MYSQL_ROOT_PASSWORD="password" -p 9183:3306 mysql
-
题外话:
- 如果不指定root账号密码会导致无法启动;
- 如果数据库不是通过migration等管理,需要开账号远程权限,发现sqlyog等连接工具登不上,大概报错是:MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found 按道理这个是客户端的问题,加密插件没被正确加载,导致无法验证通过,从服务端的解决办法:ALTER USER 'mushroom'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
- 按代理可以配置文件和数据库目录错误日志等挂在出来
- redis
- docker pull redis:latest
- docker run -dit --name redis --restart always -p 9180:6379 redis --requirepass "password"
- rabbitmq
- docker pull rabbitmq:latest
- docker run -dit --name rabbitmq --restart always -e RABBITMQ_DEFAULT_USER=geekbin -e RABBITMQ_DEFAULT_PASS="password" -p 9181:15672 -p 9182:5672 rabbitmq
-
题外话
- 这里一并安装了rabbitmq manager;需要进入container启动一下
- 文档
- rabbitmq-plugins enable rabbitmq_management
- nginx
- docker pull nginx:latest
- docker run -dit --name nginx --restart always -p 80:80 -p 443:443 -v /mnt/nginx/conf:/etc/nginx/conf.d -v /mnt/nginx/logs:/var/log/nginx -v /mnt/nginx/www:/mnt/www nginx
安装redis-cli
- wget http://download.redis.io/redis-stable.tar.gz
- tar xvzf redis-stable.tar.gz
- cd redis-stable
- cp src/redis-cli /usr/bin/
网友评论