85

私は自分のオープンソースプロジェクトをherokuにデプロイしようとしています。必然的に、静的なhtmlとjavascriptだけで非常にシンプルになります。しかし、それらは静的サイトをサポートしていませんか?htmlとjavascript以外のものを使用する予定がない場合は、Sinatraプロジェクトにしたくありません。

~/sites/d4-site $ heroku create --stack cedar
Creating quiet-ice-4769... done, stack is cedar
http://quiet-ice-4769.herokuapp.com/ | git@heroku.com:quiet-ice-4769.git
Git remote heroku added


~/sites/d4-site $ git remote -v
heroku  git@heroku.com:quiet-ice-4769.git (fetch)
heroku  git@heroku.com:quiet-ice-4769.git (push)


~/sites/d4-site $ git push heroku master
Counting objects: 53, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (53/53), 206.08 KiB, done.
Total 53 (delta 4), reused 0 (delta 0)

-----> Heroku receiving push
-----> Removing .DS_Store files
 !     Heroku push rejected, no Cedar-supported app detected
4

10 に答える 10

215

簡単な方法は、HTML アプリを PHP アプリとして偽装することです。Heroku は PHP アプリを適切に識別します。

  1. index.html ファイルの名前を home.html に変更します。
  2. index.php ファイルを作成し、エントリの html ファイルを含めます。HTML エントリ ファイルの名前が推奨どおり home.html である場合、index.php は次のようになります。

    <?php include_once("home.html"); ?>

  3. プッシュ元のマシンのコマンド ラインで、次のように入力します。

    git add .
    git commit -m 'your commit message'
    git push heroku master

Heroku は、あなたのアプリを php アプリとして適切に検出するはずです:

-----> PHP app detected
-----> Bundling Apache version 2.2.22
-----> Bundling PHP version 5.3.10
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for PHP   -> web

-----> Compiled slug size: 9.9MB
-----> Launching... done, v3
...

Mad lemiffe のブログ投稿に感謝します: http://www.lemiffe.com/how-to-deploy-a-static-page-to-heroku-the-easy-way/

于 2013-07-08T16:46:03.797 に答える
13

これを行うには、ラックを使用できます。

https://devcenter.heroku.com/articles/static-sites-on-heroku

または、sinatra を使用する Octopress/Jekyll のようなものを使用できます。

ただし、html 静的コンテンツを提供するには最小限のスタックが必要です

于 2012-05-11T12:36:11.700 に答える
5

誰かが他の答えに従うのが難しいと思った場合に備えて、それを行うためのはるかに簡単な方法があります.

をルートとする静的 Web サイトがあるとしますindex.html。それを Heroku にデプロイしたいのですが、どうすればよいでしょうか?

# initialise a git repo
git init

# add the files
git add -A

# commit the files
git commit -m "init commit"

# Now add two files at the root, composer.json and index.php
touch composer.json
touch index.php

# add this line to index.php, making a PHP app that simply displays index.html
<?php include_once("index.html"); ?>

# add an empty object to composer.json
{}

実行するだけでgit push heroku master完了です。

于 2016-08-05T04:49:17.823 に答える
2

これは少し古いかもしれませんが、最終的にはVienna Gemwを使用してこれをデプロイしました.ルビーの:

require 'vienna'
run Vienna

また、これを heroku にデプロイするには、Gemfile を作成する必要があります。

source 'https://rubygems.org'
gem 'rack'
gem 'vienna'

次に bundle install を実行します。バンドル gem がインストールされていない場合は、端末で実行するだけです。

sudo gem install bundle

そして、それはほとんどです。詳細については、http: //kmikael.com/2013/05/28/creating-static-sites-in-ruby-with-rack/を参照してください。

于 2015-04-15T13:14:51.147 に答える
2

この手順に従ってください

ステップ1

タイプtouch composer.json index.php index.html

index.php タイプのステップ 2 :

<?php include_once("index.html"); ?>

そして composer.json タイプ {} で

ステップ 3

git add .

git commit -m "[your message]"

git push ['yourrepo'] ['yourbranch']
于 2019-01-09T08:08:01.280 に答える