17
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Heroku の Apache で Basic 認証を行う

Last updated at Posted at 2014-12-10

public/ を docroot とする PHP アプリケーションで、Apache を使って Basic 認証を行う。

ファイル構成は以下。(.git/ の内容や、vendor/ は除外)

$ tree -a
├── .git
├── .gitignore
├── .htpasswd
├── Procfile
├── composer.json
└── public
    ├── .htaccess
    └── index.php

.htaccess は、docroot に置く。

$ cat public/.htaccess
AuthUserFile /app/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user

.htpasswd を作成。.htpasswd は、docroot 以外に配置。

$ htpasswd -c .htpasswd user

Procfile と composer.json は、最低限のものだけ。

$ cat Procfile
web: vendor/bin/heroku-php-apache2 public/

$ cat composer.json
{
  "require": {
    "php": "~5.6.0"
  }
}

Git で、heroku にデプロイするだけ。

$ git init
$ git add .
$ git commit -m 'init'

$ heroku create
$ git push heroku origin
$ heroku open
17
16
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
17
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?