Ubuntu hyperf 部署记录

1. 安装php swoole 宇润 / PHP 环境一把梭安装工具集

// 安装php
 $ wget https://gitee.com/yurunsoft/php-env/raw/master/apt-php.sh && bash apt-php.sh
 // 安装 redis 扩展
 $ wget https://gitee.com/yurunsoft/php-env/raw/master/php-redis.sh && bash php-redis.sh
 // 安装 composer
 $ wget https://gitee.com/yurunsoft/php-env/raw/master/composer.sh && bash composer.sh
 // 安装 swoole
 $ wget https://gitee.com/yurunsoft/php-env/raw/master/install-swoole.sh && bash install-swoole.sh
 // 查看php.ini文件 添加 swoole.use_shortname="off"
 $ php --ini
 // 报错 4核8G  
 1. 解决方法 https://wenda.swoole.com/detail/107272
 2. 编译时选择no
     g++: fatal error: Killed signal terminated program cc1plus
    compilation terminated.
    make: *** [Makefile:204: ext-src/swoole_client_coro.lo] Error 1
    g++: fatal error: Killed signal terminated program cc1plus
    compilation terminated.
    make: *** [Makefile:192: ext-src/php_swoole.lo] Error 1
    g++: fatal error: Killed signal terminated program cc1plus
    compilation terminated.
 // 查看php /composer/ swoole是否安装成功
 $ php -v
 $ composer -v
 $ php --ri swoole 
    swoole

    Swoole => enabled
    Author => Swoole Team <team@swoole.com>
    Version => 4.6.7
    Built => May 28 2021 17:15:13
    coroutine => enabled with boost asm context
    epoll => enabled
    eventfd => enabled
    signalfd => enabled
    cpu_affinity => enabled
    spinlock => enabled
    rwlock => enabled
    openssl => OpenSSL 1.1.1f  31 Mar 2020
    dtls => enabled
    http2 => enabled
    pcre => enabled
    zlib => 1.2.11
    mutex_timedlock => enabled
    pthread_barrier => enabled
    futex => enabled
    mysqlnd => 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 => Off => Off
    swoole.unixsock_buffer_size => 8388608 => 8388608

2. 安装hyperf

$ composer create-project hyperf/hyperf-skeleton hyperf
$ composer update -o

3. 安装supervisor

$ sudo apt-get install -y supervisor
// 返回如下 需要更新:
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Unable to locate package supervisor
// 更新
$ sudo apt-get update 
// 生成默认配置文件
$ echo_supervisord_conf > /etc/supervisord.conf
// 搜索原配置
;[include]
;files = relative/directory/*.ini
// 修改如下 如无文件 自行创建
[include]
files = etc/supervisor/conf.d/*.conf
// 使用默认文件启动supervisor
$ supervisord -c /etc/supervisord.conf
// 添加配置
        [program:hyperf]
        process_name=%(program_name)s_%(process_num)02d
        command=php /var/www/hyperf/bin/hyperf.php start
        autostart=true
        autorestart=true
        user=root
        startsecs=10
        startretries=3
        redirect_stderr=true
        stdout_logfile=/tmp/hyperf.error.log
// 查看所有进程的状态
$ supervisorctl status
// 重新启动配置中的所有程序
$ sudo supervisorctl reread 
// 配置文件修改后使用该命令加载新的配置
$ sudo supervisorctl update  
// 启动服务
$ sudo supervisorctl start hyperf:*
// 停止服务
$ supervisorctl stop hyperf:*
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 1

开源环境历来都有大学问,楼主辛苦了!

2年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!