sudo cp /private/etc/php.ini.default /private/etc/php.ini
sudo nano php.ini
修改文件內容
max_execution_time = 1000
memory_limit=1024M
更改 apache 根目錄路徑:
vim /etc/apache2/httpd.conf
將以下內容更改為自訂的資料夾路徑,如:
DocumentRoot “/Users/Camel/www”
<Directory “/Users/Camel/www”>
設定你的apachect (這個用來解決讀取權限問題)
sudo chmod -R 777 /網站目錄
修改 \apache2\conf\httpd.conf
<code>
原來的…
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>改成…
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
問題1:
Database Exception — yii\db\Exception
SQLSTATE[HY000] [2002] No such file or directory
解決方法:
'db' => [//数据库配置,这里的配置可能会被conf/db.local main-local.php配置覆盖
'class' => yii\db\Connection::className(),
'dsn' => 'mysql:host=localhost;dbname=yii2advanced',
'username' => 'root',
'password' => '123456',
'charset' => 'utf8',
'tablePrefix' => 'jd_',
],
這邊的localhost 改成127.0.0.1
問題2:gii環境無法開啟
把config下面的main.php的後綴註解掉,使用後綴是不能開的
//'suffix' => '.html',//后缀,如果设置了此项,那么浏览器地址栏就必须带上.html后缀,否则会报404错误
main.local下面的 if (YII_ENV_DEV) 這邊是開啟gii的設定
然后,可以通过以下 URL 访问 Gii :
http://localhost/path/to/index.php?r=gii
如果开启了 pretty URLs, 则这样访问:
http://localhost/path/to/index.php/gii