# Apache 수동 설치

## 1. 사전 조사 <a href="#id-1" id="id-1"></a>

Apache의 실행 경로, 프로세스 소유자, 설정 파일 등을 확인하여 환경을 파악합니다.

* Apache 프로세스 확인

```bash
ps -ef | grep httpd
```

```bash
ps -ef | grep apache
```

```
→ Apache 실행 파일 경로 및 명령 파라미터 확인 (=readlink /proc/$(pid)/exe)
 apache process owner 확인
```

* Apache 설정 파일 경로 확인

```bash
httpd | apache2 -V
```

* Apache 버전 확인

```bash
httpd | apache2 -v
```

### 1-1. 서비스 등록 상태 확인 <a href="#id-1-1" id="id-1-1"></a>

```bash
service httpd | apache2 status
```

### 1-2. Apache 서비스 리로드 <a href="#id-1-2" id="id-1-2"></a>

```bash
service httpd | apache2 reload
```

```bash
${apache2dir}/bin/apachectl graceful
```

```bash
${apache2dir}/bin/httpd -k graceful
```

### 1-3. 설정 파일 경로 확인 <a href="#id-1-3" id="id-1-3"></a>

* 표준 설치 경로

```
 /etc/httpd/conf.d/
 /etc/httpd/conf/httpd.conf
 IncludeOptional conf.d/*.conf
```

* 사용자 정의 설치 경로

```
/usr/local/apache2/conf/extra/
/usr/local/apache2/conf/httpd.conf
Include conf/extra/plura.conf
```

설정 파일 마지막 라인에 `Include` 추가

## 2. 표준 설치: PLURA 모듈 및 설정 파일 추가 <a href="#id-2" id="id-2"></a>

설치환경의 표준 설치 경로에 `plura.conf` 파일과 모듈 파일을 다운로드합니다.

```bash
curl https://repo.plura.io/v4/module/apache/centos/plura.conf -o /etc/httpd/conf.d/plura.conf
```

```bash
curl https://repo.plura.io/v4/module/apache/centos/x86_64/7/2.4/mod_plura_module.so -o /etc/httpd/modules/mod_plura_module.so
```

## 3.  사용자 정의 설치: PLURA 모듈 및 설정 파일 추가 <a href="#id-3" id="id-3"></a>

사용자 정의 경로에 `plura.conf` 파일과 모듈 파일을 다운로드합니다.

```bash
curl https://repo.plura.io/v4/module/apache/centos/plura.conf -o /usr/local/apache2/conf/extra/plura.conf
```

```bash
curl https://repo.plura.io/v4/module/apache/centos/x86_64/7/2.4/mod_plura_module.so -o /usr/local/apache2/modules/mod_plura_module.so
```

* `plura.conf` 파일 내용

```
 LoadModule mod_plura_module modules/mod_plura_module.so
 mp_log /var/log/plura/weblog.log
```

## 4. 정보 등록 <a href="#id-4" id="id-4"></a>

설치가 완료되면, 다음 명령어를 통해 PLURA 정보를 `/etc/modplura` 파일에 등록합니다.

```bash
echo ModPlura-Apache > /etc/modplura
```

```bash
echo 5.5.3 >> /etc/modplura
```

```bash
echo /usr/sbin/httpd >> /etc/modplura
```

```bash
echo /etc/httpd >> /etc/modplura
```

```bash
echo /etc/httpd >> /etc/modplura
```

```bash
echo centos/x86_64/7/2.4 >> /etc/modplura
```

```bash
touch /etc/.modplura
```

## 5. 사용자 정의 설치: 정보 등록 <a href="#id-5" id="id-5"></a>

사용자 정의 설치의 경우, 다음 명령어로 PLURA 정보를 추가합니다.

```bash
echo /usr/local/apache2/bin/httpd >> /etc/modplura
```

```bash
echo /usr/local/apache2 >> /etc/modplura
```

```bash
echo /usr/local/apache2 >> /etc/modplura
```

## 6. 권한 설정 <a href="#id-6" id="id-6"></a>

{% hint style="warning" %}
PLURA 웹 로그 파일을 Apache 워커 프로세스의 소유자로 변경하고 권한을 조정합니다.
{% endhint %}

```bash
chown apache /var/log/plura
```

```bash
chmod 755 /var/log/plura
```

```bash
chmod +x /etc/httpd/modules/mod_plura_module.so
```

* SELinux 설정

```bash
chcon -h system_u:object_r:httpd_sys_content_t:s0 /etc/httpd/conf.d/plura.conf
```

```bash
chcon -h system_u:object_r:httpd_sys_content_t:s0 /etc/httpd/modules/mod_plura_module.so
```

```bash
restorecon /etc/httpd/conf.d/plura.conf
```

```bash
restorecon /etc/httpd/modules/mod_plura_module.so
```
