본문 바로가기
2023_국민대/AI 개발 환경의 이해

[Linux] 웹 서버 구축 Apache

by yejineee 2023. 4. 15.

Apache

세계에서 가장 많이 쓰는 웹 서버 중 하나

Apache 재단에서 만든 HTTP 서버

정적인 데이터를 처리하는 웹 서버로 무료 오픈 소스

다양하고 기능적인 면에서 우수

구축이 쉬워 많이 사용


Apache web server 설치

# apt-get update

  • 레포지토리 갱신

# apt-get install apache2

  • apache 설치

Apache server 확인

# systemctl status apache2

  • apache 서비스 상태 확인

# systemctl enable apache2

  • 항상 서비스 상태 active

Apache web server 구동 확인

Firefox web browser를 열어 apache web server가 구동 중인지 확인

  • http://127.0.0.1 (local host IP)

Apache web server 가상 호스트 설정

# ip addr

  • 현재 VM IP 확인

/etc/hosts 파일에 서버의 IP 주소 및 로컬 도메인 이름 설정

 

# mkdir -p /var/www/html/example.com/

  • example.com 도메인의 문서 루트 디렉토리를 생성

# chmod -R 775 /var/www/html/example.com/

# chown -R www-data:www-data /var/www/html/example.com

  • 디렉토리에 대한 권한 설정

웹사이트의 루트 디렉토리에 사이트에 대한 테스트 html 색인 페이지 생성

(/var/www/html/example.com/index.html)

  • # vi /var/www/html/example.com/index.html
<html>
 <head>
 <title>Welcome to
Example.com!</title>
 </head>
 <body>
 <h1>The example.com virtual
host is working!</h1>
 </body>
</html>
  • # cat /var/www/html/example.com/index.html

가상호스트 파일 생성

(/etc/apache2/sites-available/example.com.conf)

  • # vi /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
	ServerName example.com
	ServerAlias www.example.com
	ServerAdmin [email protected]
	DocumentRoot /var/www/html/example.com/
	ErrorLog ${APACHE_LOG_DIR}/example.com_error.log
	CustomLog ${APACHE_LOG_DIR}/example.com_access.log combined
</VirtualHost>
  • # cat /etc/apache2/sites-available/example.com.conf

# a2ensite example.com.conf

  • a2itite 유틸리티를 사용하여 사이트 구성 활성화

# apache2ctl configtest

  • Apache2 구성 오류 테스트

# systemctl restart apache2

  • Apache 서비스 재시작

FireFox web browser에서 서버 확인 (http://example.com)


 

'2023_국민대 > AI 개발 환경의 이해' 카테고리의 다른 글

[Linux] Docker 개발 환경  (0) 2023.04.16
[Linux] Docker  (0) 2023.04.16
[Linux] Linux 개발 환경  (1) 2023.04.15
[Linux] Virtual Box + Ubuntu Linux  (0) 2023.04.15
[Linux] Linux  (0) 2023.04.15