1. 필요한 패키지 설치
[root@localhost ~]# yum -y install wget gcc-c++ pcre-devel expat-devel
2. apache 내려받기 및 apr파일 복사
# wget http://archive.apache.org/dist/httpd/httpd-2.4.43.tar.gz
# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
# tar xvfz httpd-2.4.43.tar.gz
# tar xvfz apr-1.7.0.tar.gz
# tar xvfz apr-util-1.6.1.tar.gz
# cd httpd-2.4.43/srclib/
[root@localhost srclib]# mkdir apr apr-util
# cp -arp /root/apr-1.7.0/* ./apr
# cp -arp /root/apr-util-1.6.1/* ./apr-util
# cd ..
3. apache 설치 및 기본 설정
[root@localhost httpd-2.4.43]# ./configure --prefix=/usr/local/apache \
--with-included-apr \
--with-apr=/root/httpd-2.4.43/srclib/apr \
--with-apr-util=/root/httpd-2.4.43/srclib/apr-util \
--with-mpm=event \
--with-ssl=/usr/local/ssl \
--enable-so
# make -j 4
# make install -j 4
# vi /usr/local/apache/conf/httpd.conf
/ServerName www(입력 후 엔터)
#ServerName www.example.com:80
ServerName 127.0.0.1(바로 밑에 입력)
:wq (저장 후 나가기)
4. apache 데몬등록
# vi /etc/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
[Service]
Type=forking
PIDFile=/usr/local/apache/logs/httpd.pid
ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/usr/local/apache/bin/apachectl graceful
ExecStop=/usr/local/apache/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq (저장 후 나가기)
# systemctl daemon-reload
5. 방화벽 설정
5-1. firewalld 방화벽 사용 시
# firewall-cmd --permanent --zone=public --add-port=80/tcp
# firewall-cmd --reload
5-2. iptables 방화벽 사용 시
# iptables -I INPUT -s 0.0.0.0/0 -d 서버아이피 -p tcp --dport 80 -j ACCEPT
# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
6. apache 구동 및 확인
# systemctl start httpd
# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 토 2020-11-28 13:33:33 KST; 2s ago
Process: 127874 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 127877 (httpd)
CGroup: /system.slice/httpd.service
├─127877 /usr/local/apache/bin/httpd -k start
├─127878 /usr/local/apache/bin/httpd -k start
├─127879 /usr/local/apache/bin/httpd -k start
└─127880 /usr/local/apache/bin/httpd -k start
11월 28 13:33:33 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
11월 28 13:33:33 localhost.localdomain systemd[1]: Started The Apache HTTP Server.