Hyun의 Github 블로그
홈으로 돌아가기
Ubuntu서버 구축
VMware에 Ubuntu 24.04 설치 및 Apache 웹 서버 구축
목차
- VMware 설치 및 설정
- Ubuntu 24.04 설치
- Apache 웹 서버 설치 및 설정
1. VMware 설치 및 설정
1.1 VMware Workstation Player 다운로드 및 설치
- VMware 공식 웹사이트에 접속
Products>Free Product Downloads>VMware Workstation Player선택- 최신 버전 다운로드 및 설치 진행
1.2 VMware 설정
- VMware Workstation Player 실행
Create a New Virtual Machine선택Installer disc image file (iso)옵션 선택 후 Ubuntu 24.04 ISO 파일 선택- 가상 머신 이름 및 위치 설정
- 디스크 크기 설정 (권장: 20GB 이상)
Finish클릭하여 가상 머신 생성
2. Ubuntu 24.04 설치
2.1 Ubuntu 24.04 ISO 파일 다운로드
- Ubuntu 공식 웹사이트에서 최신 버전의 Ubuntu 24.04 ISO 파일 다운로드
2.2 가상 머신에 Ubuntu 설치
- 생성한 가상 머신 실행
- 언어 선택 (한국어 또는 영어)
Install Ubuntu선택- 키보드 레이아웃 설정
- 네트워크 설정 (인터넷 연결 확인)
- 업데이트 및 기타 소프트웨어 선택 (권장:
Normal installation및Download updates while installing Ubuntu선택) - 설치 유형 선택 (
Erase disk and install Ubuntu선택) - 시간대 설정
- 사용자 정보 입력 (사용자 이름, 컴퓨터 이름, 비밀번호 등)
- 설치 완료 후 재부팅
3. Apache 웹 서버 설치 및 설정
3.1 Ubuntu 패키지 업데이트
sudo apt update
sudo apt upgrade -y
3.2 Apache 웹 서버 설치
sudo apt install apache2 -y
3.3 Apache 서비스 시작 및 부팅 시 자동 시작 설정
sudo systemctl start apache2
sudo systemctl enable apache2
3.4 방화벽 설정
- UFW(Ubuntu Firewall) 활성화
sudo ufw enable - Apache 트래픽 허용
sudo ufw allow 'Apache' sudo ufw status
3.5 Apache 웹 서버 확인
- 웹 브라우저 열기
- 주소창에
http://localhost입력 - Apache2 Ubuntu Default Page 확인
3.6 기본 HTML 파일 수정
- 기본 웹 페이지 파일 위치:
/var/www/html/index.html - HTML 파일 수정
sudo nano /var/www/html/index.html - 예시 내용 변경:
<!DOCTYPE html> <html> <head> <title>Welcome to Ubuntu 24.04!</title> </head> <body> <h1>It works!</h1> <p>This is the default web page for this server.</p> </body> </html> - 파일 저장 후 웹 브라우저에서 페이지 새로고침하여 변경 내용 확인
부록: 추가 설정 및 관리
A. Apache 모듈 관리
- 모듈 목록 확인
sudo apache2ctl -M - 모듈 활성화
sudo a2enmod <module_name> sudo systemctl restart apache2 - 모듈 비활성화
sudo a2dismod <module_name> sudo systemctl restart apache2
B. 가상 호스트 설정
- 가상 호스트 파일 생성
sudo nano /etc/apache2/sites-available/your_domain.conf - 예시 가상 호스트 설정
<VirtualHost *:80> ServerAdmin webmaster@your_domain ServerName your_domain ServerAlias www.your_domain DocumentRoot /var/www/your_domain ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> - 가상 호스트 활성화
sudo a2ensite your_domain.conf sudo systemctl reload apache2 - 웹 루트 디렉터리 생성 및 권한 설정
sudo mkdir /var/www/your_domain sudo chown -R $USER:$USER /var/www/your_domain sudo chmod -R 755 /var/www/your_domain
C. SSL 설정
- SSL 모듈 활성화
sudo a2enmod ssl sudo systemctl restart apache2 - Self-signed SSL 인증서 생성
sudo mkdir /etc/apache2/ssl sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache-selfsigned.key -out /etc/apache2/ssl/apache-selfsigned.crt - SSL 가상 호스트 설정
<VirtualHost *:443> ServerAdmin webmaster@your_domain ServerName your_domain DocumentRoot /var/www/your_domain SSLEngine on SSLCertificateFile /etc/apache2/ssl/apache-selfsigned.crt SSLCertificateKeyFile /etc/apache2/ssl/apache-selfsigned.key ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> - SSL 가상 호스트 활성화
sudo a2ensite default-ssl.conf sudo systemctl reload apache2
참고 자료
이 가이드를 따라 VMware에 Ubuntu 24.04를 설치하고 Apache 웹 서버를 성공적으로 구축할 수 있습니다.
댓글남기기