max_excution_time 경고 없애는 방법

max_excution_time경고

별 생각 없이 사용하고 있었는데 max_excution_time이 발생하고 있었다..너무 값이 낮은 상태라고 경고가 나오고 있었다.

.htaccess 파일 옵션 추가

.htaccess 파일은 Apache 웹 서버에서 특정 디렉터리에 대한 설정(Configurations)을 적용하기 위한 분산 설정 파일(Distributed Configuration File) 입니다.

아래 내용 처럼 php_value에 max_execution_time을 300으로 추가해주었다.
파일 위치는 워드프레스 루트 디렉토리에서 .htaccess파일에 편집하면된다.
(docker나 kubernetes환경이 아니면 다르게 설정해야 할 수 있다.)

Kubernetes Ingress 파일 내용

nginx-ingresscontroller를 사용하고 있다.
필요시 annotations에 추가 옵션으로 timeout을 조정 할 수 있다.
(참고로 SSL Offloading 구조라 TLS설정 내용은 없다.)

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: chattiboy-ing
  namespace: wp-chattiboy
  annotations:
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "90s"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "90s"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "90s"
    nginx.ingress.kubernetes.io/fastcgi-read-timeout: "90s"
spec:
  ingressClassName: nginx
  rules:
    - host: chattiboy.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: chattiboy-svc
                port:
                  number: 80
    - host: www.chattiboy.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: chattiboy-svc
                port:
                  number: 80

Docker에서 해결한방법

custom.ini를 생성

# custom.ini 
max_execution_time = 90
memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M
max_input_vars = 3000

docker-compose에 마운트

version: '3'

services:
  wordpress:
    image: wordpress:6.7.1
    volumes:
      - ./data_wp-chattiboy:/var/www/html
      - ./custom.ini:/usr/local/etc/php/conf.d/zzz-custom.ini:ro  # :ro는 읽기전용 옵션
    ports:
      - 8080:80
    restart: always
    environment:
      - WORDPRESS_DB_HOST=
      - WORDPRESS_DB_USER=
      - WORDPRESS_DB_PASSWORD=
      - WORDPRESS_DB_NAME=

증상은 일단 사라졌지만 추가 모니터링 필요.