결과
http://본인의 서버 IP:port/path 를 입력해서 위와 같이 서버의 폴더에 접근할 수 있게 만들어보자 !
준비 사항
ubuntu 서버에 apache가 설치되어 있다.
sudo apt update
sudo apt install apache2
config 파일 수정
/etc/apache2/apache2.conf 파일에서, 접근하고자 하는 폴더로의 엑세스 권한을 부여애햐 한다.
<Directory /to/your/path>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
DocumentRoot / Alias 설정
/etc/apache2/sites-available/000-default.conf 파일에서, documentroot과 Alias를 설정할 수 있다.
* DocumentRoot: 웹 서버에서 호스팅되는 웹 사이트의 루트 디렉토리. defaut는 /var/www/html이다.
* Alias: 특정 URL 경로를 파일 시스템의 특정 디렉토리에 매핑한다.
예를 들어, DocumentRoot를 아래와 같이 설정하면, http://본인의 서버 IP:port/ 에 설정한 /to/you/path가 호스팅된다.
DocumentRoot /to/your/path
Alias를 아래와 같이 설정하면, http://본인의 서버 IP:port/webpath 에 /to/your/path가 호스팅된다.
URL 경로는 자유롭게 정하면 된다.
Alias /webpath /to/your/path
DocumentRoot, Alias 중 원하는 방법을 사용하면 된다.
서비스 재시작
모든 설정을 완료한 후, 서비스를 다시 시작하고 http://<your IP>:<your port>/<url path>를 설정한 대로 진입하면 첫 사진 처럼 폴더 트리가 보일 것 이다.
sudo service apache2 restart
'Web: html ccs javascript react' 카테고리의 다른 글
express (0) | 2024.06.17 |
---|---|
CORS(Cross-Origin Resource Sharing) (0) | 2024.06.14 |
WSL 설치해서 cra 시작하기 (0) | 2023.11.04 |
mongodb 몽고DB 기본 (0) | 2023.09.07 |
[react] tailwindcss 테일윈드CSS (0) | 2023.09.05 |