CentOS에 Apache 설치하기

$ sudo yum update
$ sudo yum install httpd

Apache 실행하기

$ sudo systemctl start httpd
$ sudo systemctl enable httpd

Apache 상태확인

 

$ sudo systemctl status httpd

CentOS는 기본적으로 방화벽에서 Apache 트래픽을 막도록 세팅되어 있음

트래픽 허용으로 변경해야 함

$ sudo firewall-cmd --permanent --add-port=80/tcp
$ sudo firewall-cmd --permanent --add-port=433/tcp
$ sudo firewall-cmd --reload

CentOS에 가상호스트 구성하기

/etc/httpd/conf.d/ 디렉토리에 .conf 파일로 구성

/etc/httpd/conf.d/MyWebsite.com.conf

/etc/httpd/conf.d/TestWebsite.com.conf

vhost.conf 파일 편집

NameVirtualHost *:80 
<VirtualHost *:80> 
ServerAdmin webmaster@MyWebsite.com 
ServerName MyWebsite.com 
ServerAlias www.MyWebsite.com 
DocumentRoot /var/www/html/MyWebsite.com/public_html/ 
ErrorLog /var/www/html/MyWebsite.com/logs/error.log 
CustomLog /var/www/html/MyWebsite.com/logs/access.log combined 
</VirtualHost>

웹사이트 파일 디렉토리 생성

sudo mkdir /var/www/MyWebsite/{public_html, logs}

sudo systemctl restart httpd

728x90

+ Recent posts