sudo nano /etc/apache2/sites-available/wordpress.conf

/etc/apache2/sites-available/wordpress.conf는 워드프레스용 Apache 가상 호스트 파일입니다. 이 파일은 워드프레스 사이트의 도메인, 루트 디렉토리, 로그 경로 등과 같은 설정을 정의합니다. 아래는 워드프레스를 위한 기본 구성 예제입니다.


1. 파일 열기

다음 명령어로 파일을 엽니다:

bash
sudo nano /etc/apache2/sites-available/wordpress.conf

2. 가상 호스트 구성 추가

아래 내용을 wordpress.conf에 추가합니다. 도메인 이름과 디렉토리를 환경에 맞게 수정하세요.

기본 설정 예제:

apache

<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /var/www/html/wordpress

<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>


3. 설정 내용 설명

  • ServerAdmin: 관리자의 이메일 주소. (에러 메시지에서 표시됨)
  • ServerName: 사이트의 주 도메인 (예: yourdomain.com).
  • ServerAlias: 추가 도메인 또는 서브도메인 (예: www.yourdomain.com).
  • DocumentRoot: 워드프레스 파일이 위치한 경로.
  • <Directory>: 디렉토리 옵션.
    • AllowOverride All: .htaccess 파일에서 Apache 설정을 허용.
    • Require all granted: 디렉토리에 대한 접근 허용.
  • ErrorLog: 에러 로그 파일 경로.
  • CustomLog: 접근 로그 파일 경로.

4. HTTPS(SSL) 추가 설정 (선택)

HTTPS를 사용하려면 아래와 같은 추가 구성을 작성해야 합니다.

HTTPS 예제:

<VirtualHost *:443>
ServerAdmin admin@yourdomain.com
ServerName yourdomain.com
ServerAlias www.yourdomain.com

DocumentRoot /var/www/html/wordpress

<Directory /var/www/html/wordpress>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

SSLEngine on
SSLCertificateFile /etc/ssl/certs/yourdomain.crt
SSLCertificateKeyFile /etc/ssl/private/yourdomain.key

ErrorLog ${APACHE_LOG_DIR}/wordpress_ssl_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_ssl_access.log combined
</VirtualHost>



5. 가상 호스트 활성화

새로운 설정을 활성화합니다:

bash
sudo a2ensite wordpress.conf

6. Apache 모듈 활성화 및 재시작

아래 명령어로 Apache의 필요 모듈을 활성화하고 서버를 재시작합니다:

bash
sudo a2enmod rewrite
sudo systemctl reload apache2

7. 파일 테스트

구성이 올바른지 확인:

bash
sudo apache2ctl configtest

문제가 없다면 출력은 다음과 같습니다:

mathematica
Syntax OK

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다