4
6

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.

Webサーバ構築〜Apacheインストール・Basic認証

Last updated at Posted at 2016-02-11

[目的]
Apacheをインストールし、開発のためにBasic認証を追加する

Apacheインストール

パッケージインストール
sudo yum install httpd
Apacheのバージョン確認
apachectl -version
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov 19 2015 21:43:13
Apache起動
service httpd start
 or
apachectl start

http://IPアドレス/ にアクセスするとApache HTTP Server Test Pageが表示される

WebページにBasic認証をかける

開発中の画面を非公開にするためにBasic認証を追加する

認証用のアカウント・パスワード生成
sudo htpasswd -c -b /etc/httpd/conf/.htpasswd user1 password
[sudo] password for user1: 
Adding password for user user1
basic認証の設定追加
sudo vim /etc/httpd/conf/httpd.conf
以下を追加
<Directory "/var/www/html/">
    AuthUserFile /etc/httpd/conf/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Basic Auth"
    AuthType Basic
    Require valid-user
</Directory>
Apache再起動で設定反映
service httpd restart
 or
apachectl restart

Apacheの自動起動設定

自動起動ON
chkconfig httpd on
確認
systemctl is-enabled httpd
enabled

※PHPの実行は こちら も参照

4
6
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
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?