环境配置见ApiAdmin前期环境搭建
一、ApiAdmin安装
phpstudy启动MySQL,Nginx,redis
新建数据库apiadmin,用户apiadmin,密码123456
项目运行时要在phpstudy中打开MySQL,Nginx,redis
1. 获取官方源代码
composer create-project apiadmin/apiadmin
// 下载ApiAdmin
git clone https://gitee.com/apiadmin/ApiAdmin.git
// 下载ApiAdmin-WEB
git clone https://gitee.com/apiadmin/ApiAdmin-WEB.git
源代码要放在D:\software\progress\phpstudy_pro\WWW文件夹下。
2. 安装代码
打开ApiAdmin文件夹,composer操作
composer无法使用,在phpstudy下载,还要下载redis等,并配置全局变量,以便全局使用。
composer install
成功标记
D:\phpstudy_pro\WWW\code.com\apiadmin>composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> @php think service:discover
Succeed!
> @php think vendor:publish
File D:\phpstudy_pro\WWW\code.com\apiadmin\config\trace.php exist!
Succeed!
3. 检测环境以及配置数据库
php think apiadmin:install
a1.回车 默认值 数据库类型
a2.回车 默认值 数据库用户名apiadmin
a3.输入 root 或你修改的数据库密码123456
a4.回车 默认值 数据库地址
a5.回车 默认值 端口默认
a6.输入已建好的数据库名称 如: apiadmin
a7.回车 默认值 utf8mb4
成功标记
Database configuration updated successfully
ApiAdmin configuration updated successfully
Lock file initialization successful
4. 完成数据迁移
php think migrate:run
成功标记
All Done. Took 1.5731s
5. 构建后端路由
php think apiadmin:adminRouter
成功标记
D:\phpstudy_pro\WWW\code.com\apiadmin>php think apiadmin:adminRouter
路由构建æˆåŠŸ
6. 获取管理后台账号密码
cat install/lock.ini
username:root, password:SxJKdWvi
7. 设置Nginx
phpstudy点击设置 -> 配置文件 -> vhosts.conf
phpstudy里设置www.apiadmin.com域名的根目录为D:/software/progress/phpstudy_pro/WWW/ApiAdmin/public
server {
listen 80;
server_name www.apiadminweb.com;
root "D:/software/progress/phpstudy_pro/WWW/ApiAdmin/public";
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=/$1 last;
break;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
8. 后台访问成功
http://www.apiadminweb.com/api
{
"code":1,
"msg":"操作成功",
"data":{
"Product":"ApiAdmin",
"ApiVersion":"5.0",
"TpVersion":"6.1.4",
"Company":"ApiAdmin开发维护团队",
"ToYou":"I'm glad to meet you(终于等到你!)"
}
}
二、ApiAdmin-WEB安装
cd ApiAdmin-WEB
1. 替换项目部署的域名
ApiAdmin-WEB/src/config/index.js
baseUrl: {
dev: 'http://www.apiadminweb.com/',
pro: 'https://api.apiadmin.org/'
},
2. 安装依赖
npm install
3. 构建项目文件
npm run dev
PS D:\software\progress\phpstudy_pro\WWW\ApiAdmin-WEB> npm run dev
> apiadmin@4.1.0 dev
> vue-cli-service serve --open
INFO Starting development server...
48% building 317/376 modules 59 active D:\software\progress\phpstudy_pro\WWW\ApiAdmin-WEB\node_modules\@babel\runtime-corejs2\core-js\object\define-property.jsBrowserslist: caniuse-lite is outdated. Please run the following command: `npx browserslist --update-db`
98% after emitting CopyPlugin
DONE Compiled successfully in 3745ms 14:56:43
App running at:
- Local: http://localhost:8080/
- Network: http://192.168.10.147:8080/
前端访问http://localhost:8080/成功
4. 编译项目,生成web文件
npm run build
要在前端部署成功需要修改vue.config.js文件
productionSourceMap: false,
devServer: {
proxy: 'http://www.apiadminweb.com/'
}
删除index.js里的dev地址
baseUrl: {
dev: '',
pro: 'https://api.apiadmin.org/'
},