본문 바로가기
Linux

[linux](ubuntu 18.04) apache2 port 변경 root 변경 password 설정

by Chandler.j 2019. 11. 20.
반응형

citation : https://www.unixmen.com/install-apache2-fastcgi-ubuntu-server-14-0413-10/

port 변경 방법

1. nano ports.conf

$sudo nano /etc/apache2/ports.conf 

Listen 80  ->  원하는 포트로 변경 후 저장 ctl+x -> y 

2.nano 000-default.conf

$sudo nano /etc/apache2/sites-available/000-default.conf 


3.<VirtualHost *:80> 원하는 포트로 변경 후 저장 ctl+x -> y

 

4.아파치 서비스 재시작하기
$sudo /etc/init.d/apache2 restart

$sudo /etc/init.d/apache2 restart 

root 변경 방법

1.nano /etc/apache2/apache2.conf

$sudo nano /etc/apache2/apache2.conf

root directory 추가

<Directory /path1/path2/path3/>

        Options Indexes FollowSymLinks

        AllowOverride None

        Require all granted

</Directory>

 

2.nano /etc/apache2/sites-available/000-default.conf

$sudo nano /etc/apache2/sites-available/000-default.conf

DocumentRoot 수정

3. restart apache2

$sudo service apache2 restart

$sudo service apache2 restart

password 설정 방법

1.install apache2 apache2-utils



$sudo apt-get update
$sudo apt-get install apache2 apache2-utils

 

2. create password file

first create file with user1

$sudo htpasswd -c /etc/apache2/.htpasswd user1

add user (another_user)

$sudo htpasswd /etc/apache2/.htpasswd another_user

check contents

$cat /etc/apache2/.htpasswd

 

3.nano /etc/apache2/sites-enabled/000-default.conf

$sudo nano /etc/apache2/sites-enabled/000-default.conf

directory 사이에 아래 내용 추가

 

AuthType Basic

AuthName "Restricted Content"

AuthUserFile /etc/apache2/.htpasswd

Require valid-user

4.service apache2 restart

$sudo service apache2 restart

 

 


TOP

Designed by 티스토리