사진과 같이 웹 디렉터리 접근 시 암호 입력 설정

 

1. 아파치 설정 파일 수정

# vi /etc/apache2/apache2.conf

<Directory /var/www/> # 암호를 설정할 디렉터리를 찾거나 없으면 추가

        Options Indexes FollowSymLinks
        AllowOverride all # none에서 all로 수정
        Require all granted
</Directory>

 

 

2. 암호를 설정할 디렉터리에 .htaccess 파일을 수정 또는 추가

# vi /var/www/html/.htaccess

AuthType Basic
AuthUserFile .htpasswd
Require valid-user

 

3. password 파일 생성

# htpasswd -c /etc/apache2/.htpasswd 계정명

New password: 비밀번호 입력

Re-type new password: 비밀번호 재입력

 

 

4. 서비스 재시작

# systemctl restart apache2

+ Recent posts