Centos Stream 9+PHP8+TP8+Workerman4.1+Nginx代理SSL
由于项目需要,新到的服务器需要配置安装标题的环境,搞了两天踩了一个大坑,自己粗心了,没办法。记录一下,希望可以给您一些帮助。
一、环境需求:
centos stream9、php8以上、nginx1.24、tp8、workerman4.1、由于是内网跑的,所以用上mkcert创建证书,用nginx代理websocket的wss通讯。centos系统安装直接跳过,php和nginx安装可以参考https://blog.csdn.net/alinathz/article/details/123068577?spm=1001.2014.3001.5501
二、安装tp8和workerman4.1
1、先安装composer,命令如下:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
在来一行,把composer移动到/usr/local/bin/composer,这样就可以直接用composer了。
sudo mv composer.phar /usr/local/bin/composer
2、安装tp8
习惯安装到/var/www,所以先 cd /var/www目录下,允许下面命令安装:
composer create-project topthink/think wss_server
安装好tp8,进入“wss_server”目录,继续安装workerman,运行下面命令:
composer require workerman/gateway-worker
composer require workerman/workerman