Ubuntu 22.04 에서 Apache2 와 Tomcat9 연동하기

리눅스/APACHE|2024. 3. 29. 12:19
반응형

Ubuntu 22.04 에서 Apache2 와 Tomcat9 를 연동하는 방법입니다.

본 매뉴얼의 목적은 PHP 와 JSP 를 함께 사용하용하는데 있습니다.

설명은 최소화 하고 명령어 실행 절차만 기록하였습니다.

 

1. Apache 설치

# apt -y update

# apt -y install apache2

 

2. PHP 설치

# apt -y install php libapache2-mod-php php-mysqli

 

3. Tomcat 설치

# apt -y install default-jdk tomcat9 tomcat9-admin tomcat9-user

 

4. Mod JK 설치

Apache Tomcat 연결 모듈을 설치합니다.

# apt -y install libapache2-mod-jk

 

5. Apache 설정

아래 속성 파일을 생성합니다.

# vi /etc/apache2/workers.properties

workers.tomcat_home = /var/lib/tomcat9    # 톰캣 설치 경로
workers.java_home = /usr/lib/jvm/java-11-openjdk-amd64    # JDK 설치 경로
 
worker.list = tomcat1
 
worker.tomcat1.port = 8009
worker.tomcat1.host = localhost    # 톰캣이 다른 서버에 설치되어있으면 IP 입력
worker.tomcat1.type = ajp13
worker.tomcat1.lbfactor = 1

 

생성한 파일을 지정합니다.

# vi /etc/apache2/mods-available/jk.conf

...(생략)...

<IfModule jk_module>

    # We need a workers file exactly once
    # and in the global server
    JkWorkersFile /etc/apache2/workers.properties

...(생략)... 

 

VirtualHost 설정을 변경합니다.

(Tomcat 웹소스 디렉토리로 변경, Tomcat 처리할 확장자 추가)

# vi /etc/apache2/sites-available/000-default.conf

...(생략)...

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/lib/tomcat9/webapps/ROOT/

        JkMount /*.jsp tomcat1
        JkMount /*.json tomcat1
        JkMount /*.xml tomcat1
        JkMount /*.do tomcat1

...(생략)... 

 

Tomcat 웹소스 디렉토리에 접근할 수 있도록 디렉토리 옵션을 추가합니다.

# vi /etc/apache2/apache2.conf

...(생략)...

<Directory /var/lib/tomcat9/webapps/ROOT>
    Require all granted
</Directory>

 

6. Tomcat 설정

# vi /var/lib/tomcat9/conf/server.xml

...(생략)...

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector protocol="AJP/1.3"
               address="0.0.0.0"
               port="8009"
               secretRequired="false"
               redirectPort="8443" />

...(생략)... 

 

Apache2 와 Tomcat9 를 재시작하여 설정을 적용합니다.

# systemctl restart apache2

# systemctl restart tomcat9

 

7. 테스트

테스트를 위해 PHP, JSP 샘플 파일을 생성하고 접속해 봅니다.

# cd /var/lib/tomcat9/webapps/ROOT/

# vi index.php

<?php
echo "Good Job, PHP !!";
?>

 

# vi index.jsp

Good Job, JSP !!<br>
The current time is: <%= new java.util.Date() %>

 

서버 도메인이나 IP 로 생성한 파일에 접근해 봅니다.

# curl http://sysdocu.kr/index.php

Good Job, PHP !!

 

# curl http://sysdocu.kr/index.jsp

Good Job, JSP !!<br>

The current time is: Fri Mar 29 14:05:22 KST 2024

 

반응형

댓글()

ab 명령을 이용한 웹서버 로딩 속도 테스트

리눅스/APACHE|2024. 1. 9. 13:57
반응형

ab는 Apache HTTP server의 성능을 측정하기 위한 ApacheBench 도구로, 웹 서버에 대한 부하 테스트를 수행하는 데 사용됩니다. 다수의 요청을 동시에 보내고 서버의 응답 시간, 처리량 등을 측정하여 성능을 평가할 수 있습니다.

 

ab 명령어는 httpd 또는 apache2 를 설치하면 사용이 가능합니다.

Ubuntu 를 사용하는 경우 유틸리티 패키지만 설치하여 사용이 가능합니다.

# apt -y install apache2-utils

 

이제 사용 가능한 ab 명령으로 아래 예시처럼 실행합니다.

# ab -n 1000 -c 50 http://www.sysdocu.kr/

-n 1000 : 전체 요청 횟수는 1000번 입니다.
-c 50 : 동시에 처리되는 연결 수는 50개 입니다.
http://www.sysdocu.kr/ : 요청을 보낼 웹사이트의 주소입니다. 도메인 뒤에 슬래시 ('/') 가 꼭 있어야 합니다.

결과를 다시 살펴 보겠습니다.

 

# ab -n 1000 -c 50 http://www.sysdocu.kr/
This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking http://www.sysdocu.kr(be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        Apache/2.4.57
Server Hostname:        http://www.sysdocu.kr 
Server Port:            80

Document Path:          /
Document Length:        211 bytes

Concurrency Level:      50
Time taken for tests:   0.264 seconds
Complete requests:      1000
Failed requests:        0
Non-2xx responses:      1000
Total transferred:      682000 bytes
HTML transferred:       211000 bytes
Requests per second:    3791.34 [#/sec] (mean)
Time per request:       13.188 [ms] (mean)
Time per request:       0.264 [ms] (mean, across all concurrent requests)
Transfer rate:          2525.09 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    4   1.5      5       7
Processing:     4    9   2.4      8      25
Waiting:        2    8   2.3      8      23
Total:          5   13   2.1     13      28

Percentage of the requests served within a certain time (ms)
  50%     13
  66%     13
  75%     13
  80%     14
  90%     14
  95%     16
  98%     19
  99%     21
 100%     28 (longest request)

 

이중에서 Time taken for tests:   0.264 seconds 부분을 살펴보면 됩니다.

페이지를 모두 요청하여 응답받기까지 총 0.264초 소요되었습니다.

 

반응형

댓글()

httpd 2.4 동시접속자 수 제한 상향 조정

리눅스/APACHE|2023. 4. 5. 08:34
반응형

httpd 2.4 기준으로 테스트 하였으나 오랫동안 해온 방식이라 거의 대부분의 버전에서 적용될 것 같습니다.

httpd 2.4 의 경우 Thread 처리 방식이 세종류 (Prefork, Worker, Event) 있습니다.

소스파일을 수정하지 않으면 아무리 설정해도 높은값으로 구동이 안되고 특정 메세지 (AH00513: WARNING) 가 출력되는것을 볼 수 있습니다.

소스파일을 수정하고 컴파일 하면 메인보드 오버클럭 동작과 비슷하게 아파치 기본 한계치를 높여 좀 더 많은 사용자가 동시접속이 가능하게 할 수 있습니다. 다만 하드웨어 (CPU, RAM 등) 의 성능이 받춰줘야 많은 동시접속자를 수용해도 처리가 가능하므로, 저사양의 서버를 운영중인 분에게는 추천드리지 않습니다.

 

아파치를 설치하는 단계에서 조정해줘야 하는 부분이 있으므로 이미 설치하여 사용중인분은 페이지 맨 아랫부분 옵션 적용 먼저 해보고 Syntax 에러가 없으면 그대로 사용하셔도 됩니다.

에러가 발생하면 아파치를 재설치 해주어야 하는데, 아파치를 설치하기전 소스파일을 수정해야 합니다.

# wget https://archive.apache.org/dist/httpd/httpd-2.4.56.tar.gz

# tar xvzf httpd-2.4.56.tar.gz

# cd httpd-2.4.56

 

동시접속 최대값을 수정합니다.

여기에서는 2048명의 동시접속을 허용하도록 하겠습니다.

참고로 수정해야 할 곳 앞에 # 이 있는데 이는 주석이 아니므로 삭제하지 않도록 합니다.

# vi server/mpm/prefork/prefork.c

#define DEFAULT_SERVER_LIMIT 2048    // 기본값 : 256

 

# vi server/mpm/worker/worker.c

#define DEFAULT_SERVER_LIMIT 32    // 설정한 값에 64를 곱하면 최대 동시접속자 32 * 64 = 2048 (기본값 : 16)

 

# vi server/mpm/event/event.c

#define DEFAULT_SERVER_LIMIT 32    // 설정한 값에 64를 곱하면 최대 동시접속자 32 * 64 = 2048 (기본값 : 16)

 

httpd 설치는 생략합니다. 설치는 다른 포스팅을 참고해 주시고 ( https://sysdocu.tistory.com/397 )

./configure 명령 실행할때 아래 처럼 원하는 MPM 을 옵션으로 추가하면 됩니다.

--with-mpm=worker

아래는 httpd 설치 후 확인 방법입니다.

 

사용하는 MPM 종류

# /usr/local/apache/bin/apachectl -V |grep MPM
Server MPM:     worker

 

모듈 로드 상태

# /usr/local/apache/bin/httpd -t -D DUMP_MODULES |grep mpm
mpm_worker_module (static)

예제에서는 worker 를 사용하는것이 확인되었습니다.

# vi /usr/local/apache/conf/httpd.conf

Include conf/extra/httpd-mpm.conf    // 주석 해제

 

아래 값을 적절히 수정합니다. MaxRequestWorkers 부분이 최대 동시접속자 수 입니다.

# vi /usr/local/apache/conf/extra/httpd-mpm.conf

<IfModule mpm_worker_module>
    StartServers            32
    ServerLimit             64    // 기존에 없는 옵션이므로 추가해 줍니다
    MinSpareThreads        100
    MaxSpareThreads        500
    ThreadsPerChild         64
    MaxRequestWorkers     2048
    MaxConnectionsPerChild   0
</IfModule>

 

* 옵션 설명

- StartServers : Apache 서버 가동시 생성되는 프로세스 수

- ServerLimit : Apache 서버가 생성할 수 있는 최대 프로세스 수

                       값의 공식은 MaxRequestWorkers / ThreadsPerChild = ServerLimit 이지만 이와 같거나 큰 값으로 설정하는 것이 좋습니다.

                       (여기에서는 2048 / 64 = 32 이지만 두배 큰수로 64 를 입력)

                       이 값은 시스템의 하드웨어 성능과 용량에 따라 조정되어야 합니다.

- MinSpareThreads : 최소 유지 스레드 수

                                  프로세스는 항상 최소 설정값 (여기에서는 100) 만큼의 유휴 스레드를 유지하려고 노력합니다.

                                  이는 웹 서버의 성능을 유지하기 위해 필요한 최소한의 스레드 수입니다.

- MaxSpareThreads : 최대 유지 스레드 수

                                   웹 서버가 생성한 스레드 중에 유지할 수 있는 최대 스레드의 수 (여기에서는 500) 를 결정합니다.

                                   이 값 이상의 스레드가 생성되면, 일부 스레드는 자동으로 종료되어 시스템 자원을 절약합니다.

- ThreadsPerChild : 프로세스 당 스레드 수

                                ThreadsPerChild가 64로 설정되어 있고, MaxSpareThreads가 500으로 설정되어 있다면,

                                하나의 프로세스 내에서 최대 64개의 스레드를 생성할 수 있으며, 이 중 최대 500개의 스레드는 유지됩니다.

- MaxRequestWorkers : 최대 동시 접속자 수

                                      서버가 처리할 수 있는 최대 요청 수를 결정하는 설정으로, 이 값을 증가시키면 동시에 처리할 수 있는 요청 수가 증가합니다.

- MaxConnectionsPerChild : Apache 서버에서 한 프로세스가 처리할 수 있는 최대 연결 수 (0 : 무제한)

 

httpd 설정 문법에 이상여부를 체크해보고 데몬을 재시작하여 적용합니다.

# /usr/local/apache/bin/apachectl -t

Syntax OK

# /usr/local/apache/bin/apachectl restart

 

반응형

댓글()

httpd 에서 Redirect 또는 ErrorDocument 설정이 동작하지 않을때

리눅스/APACHE|2022. 10. 6. 15:09
반응형

VirtualHost 설정에서 리다이렉트 설정을 하였거나,

Redirect / https://sysdocu.tistory.com

 

404 에러 페이지를 별도로 만든 경우

ErrorDocument 404 /error.html

 

동작하지 않을땐 아래와 같은 부분을 체크해 봅니다.

 

[에러 로그 확인]

[Thu Oct 06 14:59:04.976450 2022] [proxy_fcgi:error] [pid 204935:tid 140273396987648] [client 192.168.10.2:51192] AH01071: Got error 'Primary script unknown'

 

[해결]

 

1) 디렉토리 옵션 변경

<Directory /home/sysdocu/public_html/*>
    AllowOverride none    # 이 부분이 all 로 되어 있다면 none 으로 변경합니다.
    Options FollowSymLinks
    Require all granted
</Directory>

 

2) 프록시 옵션 추가

ProxyErrorOverride on

 

이후 httpd 를 재시작 하고 확인하면 접근이 잘 됩니다.

 

반응형

댓글()

Rocky Linux 8.x 에서 dnf 를 이용한 APM 설치

리눅스/APACHE|2022. 9. 6. 09:37
반응형

1. APM 설치

 

1) 아파치 설치

# dnf -y install httpd

 

2) MySQL 설치

# dnf -y install mysql mysql-server

 

3) PHP 설치

 

설치 가능한 PHP 버전 출력

# dnf module list php

 

원하는 버전으로 모듈 활성화

# dnf module enable php:7.4

 

설치

# dnf -y install php php-mysqlnd

 

 

2. 기본 설정

 

# vi /etc/httpd/conf/httpd.conf

ServerName 127.0.0.1

DirectoryIndex index.html index.htm index.php

AddType application/x-httpd-php .html .htm .php
AddType application/x-httpd-php-source .phps

 

# vi /etc/php.ini

short_open_tag = On
date.timezone = "Asia/Seoul"

 

html 확장자 파일에서 사용된 php 코드도 인식할 수 있게 아래 내용을 수정합니다.

 

# vi /etc/httpd/conf.d/php.conf

<FilesMatch \.(php|phar|html|htm)$> // 두 군데

 

# vi /etc/php-fpm.d/www.conf

security.limit_extensions = // 주석 해제하고 뒤에 .htm .html 추가

 

변경 내용을 적용합니다.

 

# systemctl restart php-fpm

# systemctl restart httpd

 

반응형

댓글()

Rocky Linux 8.x 에서 Let's encrypt 설치 및 SSL 발급받기

리눅스/APACHE|2022. 9. 6. 08:58
반응형

OS 종류 및 버전에 따라 설치방법이 조금씩 다릅니다.

본 내용은 Rocky Linux 8.x 에서 설치하는 방법을 다루었습니다.

 

1. 패키지 다운로드

# dnf install epel-release mod_ssl

# dnf install certbot python3-certbot-apache

 

2. 발급

# certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): (이메일 주소 입력)

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017-w-v1.3-notice.pdf.
You must agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Account registered.

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: www.sysdocu.com
2: sub.sysdocu.com

3: test.sysdocu.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1 2  // virtualhost 설정을 가져와 도메인을 출력합니다. 발급 원하는 도메인을 공백으로 구분하여 입력합니다. 통합 인증서가 아닌, 개별 인증서로 발급 받게 됩니다.
Requesting a certificate for www.sysdocu.com and sub.sysdocu.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/www.sysdocu.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/www.sysdocu.com/privkey.pem
This certificate expires on 2022-12-04.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for www.sysdocu.com to /etc/httpd/conf/httpd-le-ssl.conf
Successfully deployed certificate for sub.sysdocu.com to /etc/httpd/conf/httpd-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://www.sysdocu.com and https://sub.sysdocu.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 

아래 파일이 생성되면서 아파치 SSL 설정이 자동으로 이루어졌습니다.

> /etc/httpd/conf/httpd-le-ssl.conf

 

설정에 이상이 없는지 확인 후 아파치를 재시작 해줍니다.

# apachectl configtest

Syntax OK

 

# systemctl restart httpd

 

이제 https:// 프로토콜을 이용해 웹페이지 접근이 가능해졌습니다.

 

3. 자동 갱신 설정

 

발급된 인증서 유효기간은 3개월이며, 만료 1개월 전부터 갱신이 가능합니다.

자동으로 발급받아질 수 있게 crontab 에 등록해 줍니다. (2개월에 한번씩 1일, 16일에 체크하여 갱신)

 

# vi /etc/crontab

01 00 01,16 */2 * root /usr/sbin/certbot renew

 

 

반응형

댓글()

Rocky Linux 8.5 에서 Let's Encrypt SSL 발급 및 Lighttpd 적용하기

리눅스/APACHE|2022. 5. 24. 15:09
반응형

Lighttpd 가 설치 되었다는 가정 하에 진행합니다.

 

1. Let's Encrypt 설치

# yum -y install certbot

 

 

2. SSL 인증서 발급
# certbot certonly --webroot -w /var/www/lighttpd -d sysdocu.tistory.com

 

그리고 lighttpd 에서 사용하기 위해 cert.pem 파일과 privkey.pem 파일을 하나의 파일로 합칩니다.

# cat /etc/letsencrypt/live/sysdocu.tistory.com/cert.pem /etc/letsencrypt/live/sysdocu.tistory.com/privkey.pem > /etc/letsencrypt/live/sysdocu.tistory.com/hap.pem

 

 

3. Lighttpd 설정 및 적용

# vi /etc/lighttpd/lighttpd.conf 

$SERVER["socket"] == ":443" {
    ssl.engine = "enable"
    ssl.pemfile = "/etc/letsencrypt/live/sysdocu.tistory.com/hap.pem"           # Combined Certificate & Private Key
    ssl.ca-file = "/etc/letsencrypt/live/sysdocu.tistory.com/chain.pem"           # Root CA
    server.name = "sysdocu.tistory.com"                                                            # Domain Name
    server.document-root = "/var/www/lighttpd"                                               # Document Root Directory
    server.errorlog = "/var/log/lighttpd/sysdocu.tistory.com_error.log"           # Lighttpd error log
    accesslog.filename = "/var/log/lighttpd/sysdocu.tistory.com_access.log"  # Lighttpd access log
}

# systemctl restart lighttpd

 

https:// 가 아닌 http:// 로 접근하는 사용자를 https 로 redirect 하는 방법입니다.

 

# vi /etc/lighttpd/lighttpd.conf

$HTTP["scheme"] == "http" {
    $HTTP["host"] == "sysdocu.tistory.com" {
        url.redirect = ("/.*" => "https://sysdocu.tistory.com$0")
    }
}

# systemctl restart lighttpd

반응형

댓글()

Rocky Linux 8.5 에서 Lighttpd + PHP + MariaDB 설치하기

리눅스/APACHE|2022. 5. 24. 13:41
반응형

1. 패키지 저장소 추가 및 최신화

# yum -y install epel-release
# yum -y update

 

 

2. Lighttpd 설치

# yum install lighttpd
# systemctl start lighttpd
# systemctl enable lighttpd

 

 

3. MariaDB 설치

# yum -y install mariadb mariadb-server
# systemctl start mariadb
# systemctl enable mariadb
# mysql_secure_installation

(모든 선택은 'Y' 로 하고 root 패스워드만 수동 입력)

 

 

4. PHP 설치

# yum -y install php php-mysqlnd php-pdo php-gd php-mbstring php-fpm lighttpd-fastcgi

# systemctl start php-fpm

# systemctl enable php-fpm

 

 

5. 설정 및 적용

# vi /etc/php-fpm.d/www.conf

user = lighttpd
group = lighttpd
listen = 127.0.0.1:9000

# vi /etc/php.ini

cgi.fix_pathinfo=1

# vi /etc/lighttpd/modules.conf

include "conf.d/fastcgi.conf"

# vi /etc/lighttpd/conf.d/fastcgi.conf

fastcgi.server += ( ".php" =>
        ((
                "host" => "127.0.0.1",
                "port" => "9000",
                "broken-scriptfilename" => "enable"
        ))
)

 

# systemctl restart php-fpm

# systemctl restart lighttpd

 

 

6. 확인

지금까지 설치했던 데몬의 상태는 아래와 같이 확인이 가능합니다.

# systemctl status lighttpd

# systemctl status php-fpm

# systemctl status mariadb

 

이제 php 소스가 정상 출력 되는지 브라우저를 통해 확인해봅니다.

http://sysdocu.tistory.com/phpinfo.php

 

 

* php 페이지 접근이 안될 경우 확인 사항

1) 내부 방화벽 (firewall, ufw, iptables, tcp wrapper 등 80번 포트 접근 허용)

2) selinux 설정 (setenforce 0 으로 해제 또는 /etc/selinux/config 수정)

 

 

반응형

댓글()

[보안 설정] HTTP 불필요한 method 취약점 제거 (Disable HTTP Trace)

리눅스/APACHE|2022. 3. 31. 14:29
반응형

TRACE method 는 cross-site tracing, basic 인증 암호를 가로챌 수 있기 때문에 불필요하다고 판단 되므로 꼭 사용해야 하는 환경이 아닐 경우 제거하도록 합니다.

 

 

1. 확인

# curl -k -X TRACE http://localhost
TRACE / HTTP/1.1
User-Agent: curl/7.29.0
Host: localhost
Accept: */*

 

 

2. 조치

간단히 httpd.conf 에 아래 옵션을 추가하여 조치가 가능합니다.

 

# vi /usr/local/apache/conf/httpd.conf

TraceEnable off

 

# /usr/local/apache/bin/apachectl restart

 

 

3. 재확인

# curl -k -X TRACE http://localhost
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method TRACE is not allowed for this URL.</p>
</body></html>

 

 

[출처] https://www.youtube.com/watch?v=_zjMrdQoK8g

 

 

 

 

반응형

댓글()

CentOS 7 에서 httpd 2.4.51, PHP 8.0 소스 설치하기

리눅스/APACHE|2021. 12. 7. 14:47
반응형

1. httpd 관련 패키지 설치

# yum -y install gcc gcc-c++  libtermcap-devel gdbm-devel zlib* libxml* freetype* libjpeg* gd-* 

# yum -y install libpng* --skip-broken pcre-devel

 

 

2. apr 설치

# cd /usr/local/src

# wget https://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

# tar xvzf apr-1.5.2.tar.gz

# cd apr-1.5.2

# ./configure --prefix=/usr/local/apr

# make

# make install

 

 

3. apr-util 설치

# cd ..

# wget https://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

# tar xvzf apr-util-1.5.4.tar.gz

# cd apr-util-1.5.4

# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

# make

# make install

 

 

4. httpd 설치

# cd ..

# wget https://archive.apache.org/dist/httpd/httpd-2.4.51.tar.gz

# tar xvzf 

# cd httpd-2.4.51

# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-ssl --enable-so 

# make

# make install

 

 

5. PHP 관련 패키지 설치

# yum -y install sqlite-devel

 

 

6. PHP 설치

# cd ..

# wget https://www.php.net/distributions/php-8.0.12.tar.gz

# tar xvzf php-8.0.12.tar.gz

# cd php-8.0.12.tar.gz

# ./configure --prefix=/usr/local/php --with-mysqli --with-openssl=/usr/local/ssl --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-zlib --disable-debug --enable-calendar --enable-ftp --enable-sockets --enable-sysvsem

# make

# make install

# cp -arp php.ini-production /etc/php.ini

 

 

6. httpd 및 PHP 기본 설정

# vi /usr/local/apache/conf/httpd.conf

ServerName localhost

<Directory /usr/local/apache/htdocs>
        Options FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>

 

# vi /etc/php.ini

short_open_tag = On

date.timezone = "Asia/Seoul"

open_basedir = "/usr/local/apache/htdocs"

반응형

댓글()

php 확장자 없이 페이지 접속 가능하게 하기

리눅스/APACHE|2021. 11. 30. 11:53
반응형

주소창에서 특정 URL 호출시 아래와 같이 파일의 확장자를 사용하지 않고

파일명 만으로 접근하게 하는 방법이 있습니다.

 

기존 접속 방식 : http://sysdocu.tistory.com/data.php

 

httpd.conf 파일을 수정하여 디렉토리 옵션에 MultiViews 를 추가합니다.

LoadModule negotiation_module modules/mod_negotiation.so // httpd 2.2 이상 버전에서 활성화 필요

<Directory /RESTAPI/html>
        Options MultiViews
        AllowOverride All
        Require all granted
</Directory>

아파치 재시작 후 아래와 같은 형태로 접근이 가능합니다.

 

 

신규 접속 방식 : http://sysdocu.tistory.com/data

 

반응형

댓글()