记录一次centos运行hyperf项目的过程

发布时间:2022-11-06 23:02:38 浏览数:44

centos运行hyperf框架

由于今天在一个全新的服务器里要运行一个hyperf项目,就顺手记录一下跑起来的全过程

1.检查环境配置

先要保证php以及swoole已经安装好了,执行php --ri swoole查看swoole扩展的信息

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.8.10
Built => Nov  6 2022 03:55:52
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2k-fips  26 Jan 2017
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.7
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608

如果下面的swoole.use_shortname显示为on的话,是没法使用hyperf的,需要在配置文件里面改成off 在php.ini里面加入这样一行swoole.use_shortname='Off' 即可。 再次输入php --ri swoole,如果显示 swoole.use_shortname => Off => Off 那么说明设置成功了

2.安装依赖

在项目目录下执行过composer install, 确保依赖都安装完成了 初次执行的时候,可能会失败,会报下面的一些错误,这是由于安装依赖时需要执行几个函数,而这几个函数由于安全原因被默认禁用了,所以需要到php.ini里面把这几个函数给取消限制。

  [Symfony\Component\Process\Exception\LogicException]                         
  The Process class relies on proc_open, which is not available on your PHP i  
  nstallation.      

去php.ini里面把函数限制解除

在disable_functions这一项里面,把proc_open和proc_get_status删掉

3.启动项目

执行命令: php bin/hyperf.php start