본문 바로가기

운영체제/Ubuntu

Ubuntu Apache VirtualHost 설정

반응형

1.아파치 설정파일 위치 확인

apache2 -V | egrep "(HTTPD\_ROOT|SERVER\_CONFIG\_FILE)"
sudo vim /etc/apache2/sites-available/000-default.conf
 

아파치 설정파일 httpd.conf, apache2.conf 위치 확인 - 제타위키

다음 문자열 포함...

zetawiki.com

 

2. Ubuntu VirtualHost 설정 파일 수정

<VirtualHost *:80>
        ServerName aaa.song.co.kr			//서버 접속 도메인
        DocumentRoot /home/frontend				//root디렉토리, 폴더경로
        ErrorLog /home/frontend/web_log/error.log				//에러로그 경로
        CustomLog /home/frontend/web_log/access.log combined	//접속로그 경로
</VirtualHost>
<VirtualHost *:80>
        ServerAdmin bbb.song.co.kr
        ServerName bbb.song.co.kr
        ErrorLog /home/service1/logs/error.log
        CustomLog /home/service2/logs/access.log common
        RewriteEngine On	//아파치 구동중에 요청되는 URL을 재작성

        ProxyPass / http://127.0.0.1:3002/ nocanon	//프록시 설정
        ProxyPassReverse / http://127.0.0.1:3002/
        ProxyRequests Off
        AllowEncodedSlashes NoDecode

        <Proxy http://127.0.0.1:3002/*>
                Order deny,allow
                Allow from all
        </Proxy>
</VirtualHost>
<VirtualHost *:8080>
        ServerAdmin webmaster@localhost
        DocumentRoot /home/backend/api
        ErrorLog /home/backend/web_log/error.log
        CustomLog /home/backend/web_log/access.log combined
</VirtualHost>

 

3. Apache2 재실행

sudo service apache2 restart

 

* Apache 재실행했을 때 구문오류 발생하는 경우 아래 위치로 이동해서 명령어 실행

cd /etc/apache2

apache2ctl configtest

 

* 구문오류 발생 상황

  • Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration. RewriteEngine을 설정했더니 아파치 error 발생
 

아파치 mod rewrite 활성화 - 제타위키

다음 문자열 포함...

zetawiki.com

sudo a2enmod rewrite

 

  • Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration. ProxyPass 설정했더니 error 발생
sudo a2enmod proxy_http

 

반응형

'운영체제 > Ubuntu' 카테고리의 다른 글

리눅스 사용자 및 그룹 관리  (0) 2023.12.26