我使用 Composer 在 Cloud9 工作区上安装了 Yii2“基本”应用程序。正如您在此处看到的那样,它运行良好 https://portfolio-php--dfmmalaw.c9.io/basic/web/index.php
问题是我在部署到 Heroku URL 后尝试查看时出现以下错误。
“禁止访问/在此服务器上。”
下面的截图是我的 Cloud9 工作区 http://prntscr.com/8rrkn0
我什至尝试将 basic/web/index.php 添加到 Heroku URL,但我只得到一个空白页面。我究竟做错了什么?
最佳答案
在获得 Herokai David Zuelke 的帮助后,我决定创建一个主题为“在 Cloud9 中创建 Yii2 应用程序 → 推送到 Github → 部署到 Heroku”的指南。请参阅下面(如果更容易阅读,顶部的谷歌文档链接):
https://docs.google.com/document/d/15teHaGWUWSNW_VwdV3-7bVpQHNRv2G0Z8GPFbIB-ogs/edit
1) 创建 Yii2“基本”应用程序:
290795 $ composer create-project --prefer-dist yiisoft/yii2-app-basic basic
2) 进入“basic”目录
290795 $ cd basic/
3) 为“basic”目录初始化本地repo
basic $ git init
4) 添加并提交 Yii 项目
basic $ git add .
basic $ git commit -m "basic Yii project"
5) 添加指向“web”目录下的index.php(入口脚本)的procfile
basic $ echo "web: vendor/bin/heroku-php-apache2 web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "Procfile for Heroku"
6) 注释掉调试内容(我手动而不是从命令行执行此操作)
basic $ vim web/index.php # remove dev/debug env stuff (not my way)
basic $ git add web/index.php
basic $ git commit -m "remove dev/debug env"
7) 这将依赖项从 v1.0.3 更新到 v1.1(绝对必要)
basic $ composer require fxp/composer-asset-plugin
basic $ git add composer.json composer.lock
basic $ git commit -m "use fxp/composer-asset-plugin in project"
8) 创建 Heroku 应用程序并推送到它。 (我改为创建并推送到 Github 存储库)
basic $ heroku create
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
9) 为 Yii 应用程序添加日志记录到 Heroku(没有开箱即用的 Yii 日志记录)
basic $ echo "web: vendor/bin/heroku-php-apache2 -l runtime/logs/app.log web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "tail runtime/logs/app.log"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
10) 这允许“联系”页面工作(不知道为什么)
basic $ composer require ext-gd:* --ignore-platform-reqs
basic $ git add composer.json composer.lock
basic $ git commit -m "require GD for contact CAPTCHA"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
关于php - Yii2 应用程序未显示在 Heroku 域上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33160064/