我使用名为index.html的索引文件开发纯前端应用程序。每次我推送到heroku,我需要将其重命名为index.php,以告诉heroku使用php。是否有另一种方法来声明我想要的服务器类型?这样我就可以将我的文件保存为html文件?是否可以将index.html推送到heroku?
2
A
回答
5
您也可以将一个空的composer.json
放入您的项目中,以使Heroku将您的项目视为一个PHP项目。
index.php
优于index.html
来自Apache在Heroku上使用的默认指令DirectoryIndex
;它与你的浏览器无关。要更改它,您可以将.htaccess
与DirectoryIndex index.html
放入您的应用程序中。
如果你只是想要静态网站的原始性能,那么使用Nginx也可能是一个好主意。默认配置应该是合理的为您的目的,所以添加Procfile
与web: vendor/bin/heroku-php-nginx
您的项目连同一个空的composer.json
(和index.php
),并且你很好去。
有关更多详细信息,另请参阅https://devcenter.heroku.com/articles/php-support和https://devcenter.heroku.com/articles/custom-php-settings。
2
你可以做到这一点简单node.js应用与ExpressJS;
让我们说你的项目文件夹中有一个名为public
子文件夹,
var express = require('express');
var app = express();
app.use('/', express.static(__dirname + '/public'));
var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
console.log('Your files will be served through this web server')
});
保存此代码app.js,把你静态文件public
文件夹下,并准备你的Procfile
最后的文件夹结构将会;
yourproject
--public/
----your staticfiles
--app.js
--Procfile
Procfile
将;
web: node app.js
并部署您的项目。当你请求你的静态文件时; .../index.html
,index.html
将在公共文件夹下提供
-1
添加一个名为index.php的空文件,这将被heroku使用,但index.html将由浏览器优先。
相关问题
- 1. 将heroku推送到github
- 2. 将mysql推送到heroku
- 3. 是否可以将SqlServer触发器推送到ActiveMQ
- 4. 是否可以将KML推送到Google地球?
- 5. 是否可以将短信推送到附近的手机?
- 6. 可以推送到heroku,但获得权限时拒绝推git
- 7. 是否可以从UINavigationController中推送UITabbarController?
- 8. 推送器是否可以使用Phonegap
- 9. 是否可以在heroku上部署jar而不是推送源代码?
- 10. 无法推送到Heroku推送拒绝
- 11. 将应用推送到heroku错误
- 12. 将代码推送到Heroku时出错
- 13. 将Dockerfile或docker-compose推送到heroku
- 14. 将内置文件推送到heroku
- 15. 如何将ejabberd推送到heroku
- 16. 无法将Django项目推送到Heroku
- 17. 如何将Procfile推送到Heroku?
- 18. 无法将代码推送到heroku
- 19. 我可以将标签推送到当前推送的git吗?
- 20. Heroku推送 - Git推送到Heroku的错误
- 21. 未能推送到heroku
- 22. 推送到Heroku的麻烦
- 23. production.rb未被推送到heroku
- 24. 无法推送到heroku
- 25. 推送到heroku失败
- 26. 超时推送到Heroku
- 27. 是否可以从git服务器推送到客户端?
- 28. 推送通知收到后是否可以修改?
- 29. 是否可以检测推送通知到达?
- 30. 我可以告诉iOS设备是否收到推送通知?
你不能直接提供静态文件,但你可以通过简单的node.js应用程序来管理它。看到我的答案[这里](http://stackoverflow.com/questions/23564500/is-it-possible-to-push-a-index-html-to-heroku/23564786#23564786) –