LoginSignup
6

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の実行は こちら も参照

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
6