php yii环境配置,yii2-基础 搭建博客 - 安装yii2 配置环境

本文详细介绍了如何使用npm安装Yii2框架,配置数据库连接(包括MySQL和MongoDB),以及如何设置Nginx环境以配合Yii2应用。后续还将涉及用户模型的创建。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

##1. 安装 (npm方法安装)

### 查看版本

##1.下载安装yii2

composer create-project yiisoft/yii2-app-advanced my-blog

下载完成后在  environments/dev/common/config/main-local.php

配置基本数据库信息

```

return [

'components' => [

'db' => [

'class' => 'yii\db\Connection',

'dsn' => 'mysql:host=localhost;dbname=yii2advanced',

'username' => 'root',

'password' => '',

'charset' => 'utf8',

],

'mailer' => [

'class' => 'yii\swiftmailer\Mailer',

'viewPath' => '@common/mail',

// send all mails to a file by default. You have to set

// 'useFileTransport' to false and configure a transport

// for the mailer to send real emails.

'useFileTransport' => true,

],

],

];

```

2.配置nginx   --》不再说明

执行 php init 初识化配置信息

因为我用的mongodb所以需要配置下mongogii

0e82aee23a3d

mongo用户表结构

用户表

id  username   phone  email  password  password_hash status type createTime  updateTime

生成user modle

0e82aee23a3d

-----未完待续-----

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值