Listen 80 -- 사용할 포트
ServerName localhost
// vhost를 사용할 경우 주석 해제
Include conf/extra/httpd-vhosts.conf
// ssl을 사용할 경우 주석 해제
Include conf/extra/httpd-ssl.conf
설정에 문제 없는지 확인해보기
apachectl configtest
vhost를 사용하는 경우 이렇게 나올거다.
// AH00112: Warning: DocumentRoot [/usr/local/apache/docs/dummy-host.example.com] does not exist
그럼 httpd-vhost.conf 파일을 열어서 DocumentRoot를 내게 맞게 설정한다. (html 파일이 있는곳으로 설정)
ssl을 사용하는 경우는 이렇게 나올거다.
AH00526: Syntax error on line 144 of /usr/local/apache/conf/extra/httpd-ssl.conf:
SSLCertificateFile: file '/usr/local/apache/conf/server.crt' does not exist or is empty
-- ssl 인증서 없이 사용할 경우
<VirtualHost *:80>
ServerName mysite.co.kr
ServerAlias www.mysice.co.kr
DocumentRoot /home/test/htdocs
<Directory /home/test/htdocs>
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
JkMount /* mysitebalancer --> 사용하지 않는 경우 삭제해도 됨.
</VirtualHost>
-- ssl 인증서 사용할 경우 http -> https로 리다이렉트
<VirtualHost *:80>
ServerName mysite.co.kr
ServerAlias www.mysice.co.kr
DocumentRoot /home/test/htdocs
<Directory /home/test/htdocs>
Order allow,deny
Allow from all
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
# JkMount /* mysitebalancer
</VirtualHost>
vi apache/conf/extra/httpd-ssl.conf
<VirtualHost *:443>
ServerName mysite.co.kr
ServerAlias www.mysice.co.kr
SSLEngine on
SSLCertificateFile conf/cert/mysite/mysite.co.kr.crt
SSLCertificateKeyFile conf/cert/mysite/mysite.co.kr.key
SSLCACertificateFile conf/cert/mysite/chainca.crt
DocumentRoot /home/test/htdocs
<Directory /home/test/htdocs>
Order allow,deny
Allow from all
Options FollowSymLinks
#Options Indexes
AllowOverride All
Require all granted
</Directory>
JkMount /* mysitebalancer
</VirtualHost>