没有不值得去解决的问题,也没有不值得去学习的技术!

Installing yii2-starter-kit on Windows 10 with Nginx 1.10: Implementation and Troubleshooting

Opening the backend application works normally

1. Installing yii2-starter-kit on Windows 10 and Nginx 1.10, run the following in the command line: php console/yii app/setup, as shown in Figure 1

Installing yii2-starter-kit, run in the command line: php console/yii app/setup
Installing yii2-starter-kit, run in the command line: php console/yii app/setup

2. Error: create unique index idx_article_slug on {{%article}} (slug) …Exception: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes, as shown in Figure 2
Translation: Create unique index idx_article_slug on {{%article}} (slug) …Exception: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

3. Creating the index idx_article_slug on the slug field failed, as shown in Figure 3

SQL: ALTER TABLE `article` ADD UNIQUE INDEX `idx_article_slug` (`slug`)
#1071 – Specified key was too long; max key length is 767 bytes

Creating the index idx_article_slug on the slug field failed
Creating the index idx_article_slug on the slug field failed

4. Locate the slug field in the {{%article_category}} and {{%article}} tables and change its length to 255, because both tables have index creation operations, as shown in Figure 4

Locate the slug field in the {{%article_category}} and {{%article}} tables and change its length to 255
Locate the slug field in the {{%article_category}} and {{%article}} tables and change its length to 255

5. Clear the database and run php console/yii app/setup again in the command line; it prompts that the migration was successful, as shown in Figure 5

Clear the database and run php console/yii app/setup again in the command line; it prompts that the migration was successful
Clear the database and run php console/yii app/setup again in the command line; it prompts that the migration was successful

6. Opening the frontend application returns the error: symlink(): Cannot create symlink, error code(1314), as shown in Figure 6

Opening the frontend application returns the error: symlink(): Cannot create symlink, error code(1314)
Opening the frontend application returns the error: symlink(): Cannot create symlink, error code(1314)

7. Because the development environment does not support symlink(), I decided to set ‘linkAssets’ => true by editing the file: .dev, as shown in Figure 7
LINK_ASSETS=false

Because the development environment does not support symlink(), I decided to set 'linkAssets' => true by editing the file: .dev
Because the development environment does not support symlink(), I decided to set ‘linkAssets’ => true by editing the file: .dev

8. The frontend application now opens normally, as shown in Figure 8

The frontend application opens normally
The frontend application opens normally

9. Opening the About page returns a 404, as shown in Figure 9

Opening the About page returns a 404
Opening the About page returns a 404

10. Analyzing the cause, I found that URL rewriting was enabled but Nginx did not support it. I edited nginx.conf, as shown in Figure 10
try_files $uri $uri/ /index.php?$args;

Analyzing the cause, I found that URL rewriting was enabled but Nginx did not support it. I edited nginx.conf
Analyzing the cause, I found that URL rewriting was enabled but Nginx did not support it. I edited nginx.conf

11. Opening the About page again works normally, as shown in Figure 11

Opening the About page again works normally
Opening the About page again works normally

12. Opening the backend application works normally, as shown in Figure 12

Opening the backend application works normally
Opening the backend application works normally

13. An alternative solution to point 7 is to run the console as an administrator, which resolves the issue of symlink() not being supported, as shown in

Running the console as an administrator resolves the issue of symlink() not being supported
Figure 13

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系