Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
5
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

Organization

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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
5
Help us understand the problem. What are the problem?