centos7+lnmp环境下安装Hyperf框架运行步骤流程

管理员 发布于 4个月前   108

准备工作

1.为了方便我直接用的lnmp环境

2.composer已安装

3.swoole扩展已安装 (具体步骤可以搜索我的博客文章)


php.ini配置文件的修改项目

1.并关闭Short Name

swoole.use_shortname=Off

2.搜索disable_functions(php中禁用函数) 并删除proc_open ,proc_get_status 函数

不然composer项目的时候会遇到以下错误

The Process class relies on proc_open, which is not available on your PHP installation.;
proc_get_status() has been disabled for security reasons;


开始安装项目 (我这里的安装目录是/home/www/)

[root@hyperf ~]# cd /home/www
[root@hyperf www]# ll
总用量 0
[root@hyperf www]# composer create-project hyperf/hyperf-skeleton
Creating a "hyperf/hyperf-skeleton" project at "./hyperf-skeleton"
Installing hyperf/hyperf-skeleton (v2.1.2)
  - Installing hyperf/hyperf-skeleton (v2.1.2): Extracting archive
Created project in /home/www/hyperf-skeleton
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
> Installer\Script::install
Setting up optional packages
Setup data and cache dir
Removing installer development dependencies
  What time zone do you want to setup ?
  [n] Default time zone for php.ini
Make your selection or type a time zone name, like Asia/Shanghai (n):
n
  Do you want to use Database (MySQL Client) ?
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (yes): y
  - Adding package hyperf/database (~2.1.0)
  - Adding package hyperf/db-connection (~2.1.0)
  Do you want to use Redis Client ?
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (yes): y
  - Adding package hyperf/redis (~2.1.0)
  - Copying config/autoload/redis.php
  Which RPC protocol do you want to use ?
  [1] JSON RPC with Service Governance
  [2] JSON RPC
  [3] gRPC
  [n] None of the above
  Make your selection or type a composer package name and version (n): n
  Which config center do you want to use ?
  [1] Apollo
  [2] Aliyun ACM
  [3] ETCD
  [n] None of the above
  Make your selection or type a composer package name and version (n): n
  Do you want to use hyperf/constants component ?
  [y] yes
  [n] None of the above
  Make your selection (n): y
  - Adding package hyperf/constants (~2.1.0)
  - Copying app/Constants/ErrorCode.php
  - Copying app/Exception/BusinessException.php
  Do you want to use hyperf/async-queue component ? (A simple redis queue component)
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (n): y
  - Adding package hyperf/async-queue (~2.1.0)
  - Copying config/autoload/async_queue.php
  - Copying app/Process/AsyncQueueConsumer.php
  - Copying app/Listener/QueueHandleListener.php
  - Copying config/autoload/redis.php
  Do you want to use hyperf/amqp component ?
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (n): y
  - Adding package hyperf/amqp (~2.1.0)
  - Copying config/autoload/amqp.php
  Do you want to use hyperf/model-cache component ?
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (n): y
  - Adding package hyperf/model-cache (~2.1.0)
  - Copying app/Model/Model.php
  - Copying config/autoload/databases.php
  - Copying config/autoload/redis.php
  Do you want to use hyperf/elasticsearch component ?
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (n): y
  - Adding package hyperf/elasticsearch (~2.1.0)
  Do you want to use hyperf/tracer component ? (An open tracing protocol component, adapte with Zipkin etc.)
  [y] yes
  [n] None of the above
  Make your selection or type a composer package name and version (n): y
  - Adding package hyperf/tracer (~2.1.0)
  - Copying config/autoload/opentracing.php
Remove installer
Removing composer.lock from .gitignore
Removing Expressive installer classes, configuration, tests and docs
Loading composer repositories with package information
Updating dependencies
Lock file operations: 132 installs, 0 updates, 0 removals
  - Locking composer/semver (3.2.4)
...
  - Locking webmozart/assert (1.10.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 132 installs, 0 updates, 0 removals
  - Downloading doctrine/lexer (1.2.1)
...
  - Downloading swoole/ide-helper (4.6.4)
  - Installing doctrine/lexer (1.2.1): Extracting archive
...
  - Installing swoole/ide-helper (4.6.4): Extracting archive
34 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating optimized autoload files
> rm -rf runtime/container
62 packages you are using are looking for funding.
Use the `composer fund` command to find out more!


到这就是composer完项目了


启动项目

[root@hyperf ~]# cd /home/www
[root@hyperf www]# ll
总用量 4
drwxr-xr-x. 9 root root 4096 3月  24 14:55 hyperf-skeleton
[root@hyperf www]# cd hyperf-skeleton/
[root@hyperf hyperf-skeleton]# ll
总用量 364
drwxr-xr-x.  8 root root    102 3月  24 14:54 app
drwxr-xr-x.  2 root root     24 2月  22 17:38 bin
-rw-r--r--.  1 root root   2545 3月  24 14:55 composer.json
-rw-r--r--.  1 root root 343393 3月  24 14:55 composer.lock
drwxr-xr-x.  3 root root     79 2月  22 17:38 config
-rw-r--r--.  1 root root    580 2月  22 17:38 deploy.test.yml
-rw-r--r--.  1 root root   1455 2月  22 17:38 Dockerfile
-rw-r--r--.  1 root root    474 2月  22 17:38 phpstan.neon
-rw-r--r--.  1 root root    695 2月  22 17:38 phpunit.xml
-rw-r--r--.  1 root root   1797 2月  22 17:38 README.md
drwxrwxr-x.  2 root root      6 3月  24 14:49 runtime
drwxr-xr-x.  3 root root     64 2月  22 17:38 test
drwxr-xr-x. 43 root root   4096 3月  24 14:56 vendor
[root@hyperf hyperf-skeleton]# php bin/hyperf.php start
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Config\Listener\RegisterPropertyHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\DbConnection\Listener\RegisterConnectionResolverListener listener.
[DEBUG] Event Hyperf\Framework\Event\BeforeMainServerStart handled by Hyperf\Amqp\Listener\BeforeMainServerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\BeforeMainServerStart handled by Hyperf\Process\Listener\BootProcessListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\MainWorkerStart handled by Hyperf\Amqp\Listener\MainWorkerStartListener listener.
[INFO] Worker#0 started.
[INFO] HTTP Server listening at 0.0.0.0:9501
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnManagerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#1 started.
[INFO] Process[queue.default.0] start.
[DEBUG] Event Hyperf\Process\Event\BeforeProcessHandle handled by Hyperf\Process\Listener\LogBeforeProcessStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Process\Event\BeforeProcessHandle handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.


项目已启动,我们直接到访问一下

1.png


请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

该博客于2020-12-7日,后端基于go语言的beego框架开发
前端页面使用Bootstrap可视化布局系统自动生成

是我仿的原来我的TP5框架写的博客,比较粗糙,底下是入口
侯体宗的博客

      订阅博客周刊

文章归档

  • 2021-03         (4篇)

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客