泰安专业网站建设,校园网站建设特色,个人网站域名怎么取,制作网站需要多少费用m系列 mac 安装 php 与 hyperf 框架依赖的扩展并启动 gptlink 项目
gptlink 项目是一个前后端一体化的 chatgpt 开源项目 gptlink 项目地址#xff1a;https://github.com/gptlink/gptlink
安装 php 8.0 版本#xff1a;
brew install php8.0安装完成后提示如下#xff…m系列 mac 安装 php 与 hyperf 框架依赖的扩展并启动 gptlink 项目
gptlink 项目是一个前后端一体化的 chatgpt 开源项目 gptlink 项目地址https://github.com/gptlink/gptlink
安装 php 8.0 版本
brew install php8.0安装完成后提示如下
To enable PHP in Apache add the following to httpd.conf and restart Apache:LoadModule php_module /opt/homebrew/opt/php8.0/lib/httpd/modules/libphp.soFilesMatch \.php$SetHandler application/x-httpd-php/FilesMatchFinally, check DirectoryIndex includes index.phpDirectoryIndex index.php index.htmlThe php.ini and php-fpm.ini file can be found in:/opt/homebrew/etc/php/8.0/php8.0 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.If you need to have php8.0 first in your PATH, run:echo export PATH/opt/homebrew/opt/php8.0/bin:$PATH ~/.zshrcecho export PATH/opt/homebrew/opt/php8.0/sbin:$PATH ~/.zshrcFor compilers to find php8.0 you may need to set:export LDFLAGS-L/opt/homebrew/opt/php8.0/libexport CPPFLAGS-I/opt/homebrew/opt/php8.0/includeTo start php8.0 now and restart at login:brew services start php8.0
Or, if you dont want/need a background service you can just run:/opt/homebrew/opt/php8.0/sbin/php-fpm --nodaemonizescrcpy
At runtime, adb must be accessible from your PATH.You can install adb from Homebrew Cask:brew install --cask android-platform-toolszsh completions have been installed to:/opt/homebrew/share/zsh/site-functions根据如上提示在 /.zshrc 文件中添加下面环境变量配置 export PATH/opt/homebrew/opt/php8.0/bin:$PATH
export PATH/opt/homebrew/opt/php8.0/sbin:$PATH添加完成后重启命令行执行 php -v 如下说明 php 安装成功
➜ php -v
PHP 8.0.29 (cli) (built: Jun 15 2023 05:07:53) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.29, Copyright (c) Zend Technologieswith Zend OPcache v8.0.29, Copyright (c), by Zend Technologies安装 composer 包管理工具:
它是 php 的包管理工具用来安装项目的依赖
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer update执行 composer update 时提示如下没有安装 php 的 swoole 扩展
96qbhy/hyperf-auth[v2.0,...v2.7.1]require e ext-swoole 4.4 -it is missing from your system
To enable extensions, verify that they are enabled in your .ini files:- /opt/homebrew/etc/php/8.0/php.ini- /opt/homebrew/etc/php/8.0/conf.d/ext-opcache.ini安装 swoole 扩展和 redis 扩展
pecl install swoole
pecl install redis安装 swoole 扩展时会提示报错如下找不到 “pcre2.h” 文件
/opt/homebrew/Cellar/php8.0/8.0.29_1/include/php/ext/pcre/php_pcre.h:23:10: fatal error: pcre2.h file not found
#include pcre2.h解决方法创建 pcre2.h 软链接到 /usr/local/include 文件夹下
// 1. 执行下面代码查看 pcre2 安装的路径找到 pcre2.h 文件的路径我这里找到的是 /opt/homebrew/include/pcre2.h 你可以看看有没有这个文件
brew info pcre2
// 2. 创建 /usr/local/include 文件夹
sudo mkdir /usr/local/include
// 3. 创建软链接
sudo ln -s /opt/homebrew/include/pcre2.h /usr/local/include/
// 4. 添加这个环境变量安装 php swoole 扩展编译时候需要
export C_INCLUDE_PATH/usr/local/include
// 5. 再次执行 pecl install swoole 一路回车就行最终 /opt/homebrew/etc/php/8.0/php.ini 增加的配置如下
extensionredis.so
extensionswoole.so
swoole.use_shortnameOff // 需要手动添加最终 composer 更新与安装
composer update
composer install依赖安装成功后启动项目
启动项目前需启动mysql和redis服务并在 gptserver 文件夹下创建 .env 文件内容如下
APP_NAMEchatgpt-link
APP_ENVprod# 数据库 通过 docker 启动命令docker run -d -p 3306:3306 --name mysql57 -e MYSQL_ROOT_PASSWORD123456 -e MYSQL_DATABASEgptlink mysql:5.7
DB_HOST192.168.30.19 # 你本机电脑的 ip 地址命令行输入 ifconfig 查看 en0
DB_PORT3306
DB_DATABASEgptlink
DB_USERNAMEroot
DB_PASSWORD123456#redis 通过 docker 启动命令docker run -d --name redis -p 6379:6379 redis
REDIS_HOST192.168.30.19
REDIS_AUTH(null)
REDIS_PORT6379# 管理员账号密码
ADMIN_USERNAMEadmin
ADMIN_PASSWORDadmin888
ADMIN_TTL7200启动php后端服务
cd gptlink/gptserver
// 初始化数据库
php ./hyperf migrate
// 启动本地后端服务
php ./hyperf start
// 端口在 http://127.0.0.1:9503 前后端设置 proxy 代理到该端口开发