본문 바로가기

Linux Server

[Linux] Ubuntu 에서 Apache 설치(컴파일)

테스트 환경

NCP 리눅스 서버 1대 생성

OS : (Linux) Ubuntu 16.04

Apache 버전 : 2.4.54

 

1) apt update

apt-get update

apt update

 

2) Java 설치

apt install openjdk-8-jdk

java -version

 

3) g++ / gcc 설치

apt install g++

apt install gcc

 

g++ --version

gcc --version

 

4) Apache 컴파일

wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz

wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz

wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz

 

tar -zxvf httpd-2.4.54.tar.gz

tar -xvzf apr-1.6.5.tar.gz

tar -xvzf apr-util-1.6.1.tar.gz

 

mv apr-1.6.5 httpd-2.4.54/srclib/apr

mv apr-util-1.6.1 httpd-2.4.54/srclib/apr-util

mkdir /apache

 

apt-get install libpcre3 libpcre3-dev

apt install libpcre3 libpcre3-dev

apt-get install libexpat1-dev

apt install libexpat1-dev

 

cd /httpd-2.4.54

./configure --prefix=/apache/httpd-2.4.54 --with-included-apr  --enable-so --enable-ssl=shared --with-ssl=/usr/local/ssl --enable-rewrite --with-included-apr-util  --with-included-pcre

 

make

make install

 

make 에러 발생시

find . -name "*.lo" -exec rm -rf {} \;

 

mkdir /usr/lib/systemd/system

vi /usr/lib/systemd/system/httpd.service

(서비스등록)

[Unit]

Description=The Apache HTTP Server

After=network.target remote-fs.target nss-lookup.target

Documentation=man:httpd(8)

Documentation=man:apachectl(8)

 

[Service]

Type=forking

PIDFile=/apache/httpd-2.4.54/logs/httpd.pid

ExecStart=/apache/httpd-2.4.54/bin/apachectl start

ExecReload=/apache/httpd-2.4.54/bin/apachectl graceful

ExecStop=/apache/httpd-2.4.54/bin/apachectl stop

 

# We want systemd to give httpd some time to finish gracefully, but still want

# it to kill httpd after TimeoutStopSec if something went wrong during the

# graceful stop. Normally, Systemd sends SIGTERM signal right after the

# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give

# httpd time to finish.

 

KillSignal=SIGCONT

PrivateTmp=true

 

[Install]

WantedBy=multi-user.target

 

vi /apache/httpd-2.4.54/conf/httpd.conf

ServerName 부분 주석 해제 , 127.0.0.1:80 입력

 

systemctl daemon-reload

systemctl start httpd

systemctl status httpd