LoginSignup
23
26

More than 5 years have passed since last update.

herokuに静的サイトをデプロイする

Last updated at Posted at 2014-08-22

herokuはデフォルトで静的サイトに対応していないのでindex.htmlしかない状態だと以下のように怒られる(デプロイできない)

!     Push rejected, no Cedar-supported app detected

このため静的サイトを置きたい時にはちょっとしたハックが必要になる模様。
方法はrubyを使う方法、nodeを使う方法、いろいろあって
今回は一番簡易的なPHPを使う方法。

1.index.phpを追加する

touch index.php

これでPHPアプリとみなされる。
composer.jsonが無いとwarningが出るけど問題ない。

2.php engineを無効にする とみせかけてしない

色々なサイトに以下で無効にできる、と書いてあるのだけれど

echo 'php_flag engine off' > .htaccess

これを追加してpushしたところinternal errorになる。
原因がわからないのでしかたなく次の方法を取ることに。

3.index.phpからindex.htmlを読み込む

<?php echo file_get_contents('index.html'); ?>

静的じゃないけどまあいいか。

参考

Herokuに手っ取り早く静的サイトをデプロイする(node版) - Qiita

Ruby - HerokuにRackでdeployする(初級編:静的HTMLページ) - Qiita

Deployment of static files to Heroku

23
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
26