Discourse 컨테이너에 PHP 7을 포함하려는 중

discourse 업데이트를 시도하고 있는데 이 명령에서 실패하고 있습니다

I, [2024-10-01T23:08:46.462452 #1]  INFO -- : > apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring
E: Package 'php7.4' has no installation candidate
E: Unable to locate package php7.4-curl
E: Couldn't find any package by glob 'php7.4-curl'
E: Couldn't find any package by regex 'php7.4-curl'
E: Package 'php7.4-fpm' has no installation candidate
E: Unable to locate package php7.4-mbstring
E: Couldn't find any package by glob 'php7.4-mbstring'
E: Couldn't find any package by regex 'php7.4-mbstring'
I, [2024-10-01T23:08:47.335246 #1]  INFO -- : Reading package lists...
Building dependency tree...
Reading state information...
Package php7.4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php7.4-fpm is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source




FAILED
--------------------
Pups::ExecError: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring failed with return #<Process::Status: pid 2912 exit 100>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in spawn'
exec failed with the params "apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring"
bootstrap failed with exit code 100
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
d87ce61f0dbfc527ede7d3c09e222eff42934608174066401b2317d05193786b
root@htd-9-feb-22-live:/var/discourse#

Discourse는 내부 NGINX를 사용하여 설치되어 있습니다.
따라서 2년 전 설치된 discourse를 업데이트하려고 하고 있습니다. 3.2에서 3.4로 업데이트하는 것 같습니다.

아래 명령어를 실행했습니다

 1465  cd /var/discourse
 1466  git pull
 1467  ./launcher bootstrap web_only && ./launcher destroy web_only && ./launcher start web_only

YAML 파일은 다음과 같습니다. 개인 정보는 제거했습니다:

# IMPORTANT: SET A SECRET PASSWORD in Postgres for the Discourse User
# TODO: change SOME_SECRET in this template

templates:
  - "templates/web.template.yml"
    #- "templates/web.ratelimited.template.yml"
  - "shared/web-only/amp/web.amp.template.yml"
    #- "shared/web_only/amp/templates/web.amp.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80" # http
  - "443:443" # https

# Use 'links' key to link containers together, aka use Docker --link flag.
links:
  - link:
      name: data
      alias: data

# any extra arguments for Docker?
# docker_args:

params:
  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  #EMBER_CLI_PROD_ASSETS: 1

  # DISCOURSE_DEFAULT_LOCALE: en
  #Global rate limits disabling rate limits to let SEO fix penalty crawling to get rid of 429 too many req error
  DISCOURSE_MAX_REQS_PER_IP_MODE: none

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 32

  ## TODO: The domain name this Discourse instance will respond to
  #DISCOURSE_HOSTNAME: hidden
  DISCOURSE_HOSTNAME:hidden

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: "hidden"

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: hidden
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: hidden
  DISCOURSE_SMTP_PASSWORD: "hidden"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: hidden
  DISCOURSE_NOTIFICATION_EMAIL: hidden

  ## If you added the Lets Encrypt template, uncomment below to get a free SSL certificate
  LETSENCRYPT_ACCOUNT_EMAIL: hidden
  ## TODO: configure connectivity to the databases
  #ljlsdfj;sdfj;lkdsfj
  DISCOURSE_DB_SOCKET: ""
  #DISCOURSE_DB_USERNAME: hidden
  DISCOURSE_DB_PASSWORD: hidden
  DISCOURSE_DB_HOST: data
  DISCOURSE_REDIS_HOST: data

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details


  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details


volumes:
  - volume:
      host: /var/discourse/shared/web-only
      guest: /shared
  - volume:
      host: /var/discourse/shared/web-only/log/var-log
      guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          #- git clone https://github.com/discourse/discourse-sitemap.git
          #- git clone https://github.com/discourse/discourse-math.git # custom plugin for math JAX support
          #- git clone https://github.com/discourse/discourse-solved.git # custom plugin for question and answers and choosing best answer
          #- git clone https://github.com/discourse/discourse-voting.git # custom plugin for voting on topics only
          #- git clone https://github.com/discourse/discourse-yearly-review.git # custom plugin for automatically posting a yearly topic of forum activity
          #- git clone https://github.com/discourse/discourse-user-notes.git # custom plugin to allow staff to add notes about a user
          #- git clone https://github.com/paviliondev/discourse-question-answer.git # custom non official plugin for SO style QnA voting on posts
          #- git clone https://github.com/discourse/discourse-adplugin.git # custom official plugin for ads
          #- git clone https://github.com/discourse/discourse-whos-online.git # custom plugin to see who is online
          #- git clone https://github.com/paviliondev/discourse-topic-previews.git # custom plugin for showing topics previews nicely
          #- git clone https://github.com/paviliondev/discourse-ratings.git # custom plugin to allow user rating on topics
          #- git clone https://github.com/discourse/discourse-cakeday.git # official plugin for birthdays and join date celebrations
          #- git clone https://github.com/discourse/discourse-saved-searches.git # official plugin for saved search notifications
          #- git clone https://github.com/paviliondev/discourse-follow.git # custom plugin to allow users to follow each other
          - git clone https://github.com/FaizanZahid/discourse-amp-htd-plugin.git # custom build AMP support for HTD
          #- git clone https://github.com/discourse/discourse-assign.git # custom for assigning topics to staff
          #- git clone https://github.com/paviliondev/x-discourse-tlp-thumbnail.git # custom plugin for showing thumbnails from CDN images
          #- git clone https://github.com/discourse/discourse-prometheus.git # custom plugin for slow speed monitoring
          #- git clone https://github.com/discourse/discourse-push-notifications.git # plugin for push notifications

## Remember, this is YAML syntax - you can only have one block with a name worker_conn was 3000
run:
  - exec: echo "Beginning of custom commands"
  - replace:
      filename: "/etc/nginx/nginx.conf"
      from: "worker_connections 768"
      to: "worker_connections 4000"
  - replace:
      filename: "/etc/nginx/nginx.conf"
      from: "worker_processes auto"
      to: "worker_processes 16"

  ## If you want to configure password login for root, uncomment and change:
  ## Use only one of the following lines:
  #- exec: /usr/sbin/usermod -p 'PASSWORD_HASH' root
  #- exec: /usr/sbin/usermod -p "$(mkpasswd -m sha-256 'RAW_PASSWORD')" root

  ## If you want to authorized additional users, uncomment and change:
  #- exec: ssh-import-id username
  #- exec: ssh-import-id anotherusername

  - exec: echo "End of custom commands"
  - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Authorized SSH keys for this container:"; } NF>=2 {print $NF;}'

사이트가 현재 다운되어 있으므로 이 문제를 해결하는 데 도움을 주실 수 있나요.

또한 다음을 실행하는 것도 고려하고 있습니다.

./launcher rebuild data

서버에는 nginx와 PHP가 설치되어 있지 않으며, 이는 내부 nginx와 내부 PHP를 사용한다는 것을 의미합니다. 그렇다면 discourse와 data 컨테이너를 수정하고 업데이트하려면 어떻게 해야 하나요?

여기서 이 줄을 삭제하세요.

@Falco 님 감사합니다 ..네, 주석을 달아두니 잘 동작하긴 하지만
AMP 페이지가 아래 스크립트를 사용하여 동작하도록 해야 하므로, 최신 PHP 버전과 호환되도록 여기서 업데이트를 해야 하는지 궁금합니다. AMP 템플릿에 주석을 달면 AMP 페이지가 동작하지 않으므로.

아래는 web.amp.template.yml 파일입니다.

hooks:
  after_ssl:
    # mkdir tmp/amp_cache/
  - exec: apt-get update
  - exec: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring
  - exec: apt-get install -y php7.4-mbstring php7.4-xml
  - exec: mkdir -p /run/php

  - replace:
      filename: "/etc/nginx/conf.d/discourse.conf"
      from: /gzip_proxied any;/
      to: |
        gzip_proxied any;
        ## BEGIN inserted by web.amp.template.ymly
        location /ads.txt {
          alias /shared/amp/ads.txt;
        }
        if ($arg_amp) { rewrite ^ /amp/index.php?q=$uri last; }

        location ~ \\.php\\$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }

        location @amp {
          rewrite ^/amp(.*) /amp/index.php?q=$1;
        }
        
        location /custom_widgets.php {
          include         fastcgi_params;
          root  /shared/amp/api/;
          fastcgi_pass    unix:/run/php/php7.4-fpm.sock;
          fastcgi_param   SCRIPT_FILENAME  /shared/amp/api/custom_widgets.php;
          fastcgi_param   QUERY_STRING     $query_string;
          fastcgi_param   REQUEST_METHOD   $request_method;
          fastcgi_param   CONTENT_TYPE     $content_type;
          fastcgi_param   CONTENT_LENGTH   $content_length;
        }
        
        
        location /amp {
          index index.php;
          try_files $uri $uri/ @amp;
          alias /shared/amp;
          location ~ \\.php$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          }
        }
        ## END inserted by web.amp.template.ymly

  - file:
     path: /etc/service/phpfpm/run
     chmod: "+x"
     contents: |
        #!/bin/sh
        exec 2>&1
        exec /usr/sbin/php-fpm7.4 --nodaemonize

  - file:
     path: /etc/runit/3.d/01-phpfpm
     chmod: "+x"
     contents: |
       #!/bin/bash
       sv stop phpfpm

거기에 어떤 변경 사항이 필요한가요?

다음과 같이 하면

hooks:
  after_ssl:
    # mkdir tmp/amp_cache/
  - exec: apt-get update
  #- exec: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring
  - exec: apt-get install -y php8.1-mbstring php8.1-xml
  #- exec: apt-get install -y php7.4-mbstring php7.4-xml
  #- exec: apt-get install -y php8.1-xml
  - exec: mkdir -p /run/php

아래와 같은 오류가 발생합니다.

nvoke-rc.d: policy-rc.d denied execution of reload.
start-stop-daemon: unable to stat /usr/libexec/polkitd (No such file or directory)
Setting up packagekit (1.2.6-5) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of force-reload.
Failed to open connection to "system" message bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Created symlink /etc/systemd/user/sockets.target.wants/pk-debconf-helper.socket → /usr/lib/systemd/user/pk-debconf-helper.socket.
Setting up packagekit-tools (1.2.6-5) ...
Setting up software-properties-common (0.99.30-4.1~deb12u1) ...
Processing triggers for dbus (1.14.10-1~deb12u1) ...

I, [2024-10-02T01:05:32.803478 #1]  INFO -- : > add-apt-repository ppa:ondrej/php
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 362, in <module>
    sys.exit(0 if addaptrepo.main() else 1)
                  ^^^^^^^^^^^^^^^^^
  File "/usr/bin/add-apt-repository", line 345, in main
    shortcut = handler(source, **shortcut_params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler
    return handler(shortcut, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 86, in __init__
    if self.lpppa.publish_debug_symbols:
       ^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 126, in lpppa
    self._lpppa = self.lpteam.getPPAByName(name=self.ppaname)
                  ^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 113, in lpteam
    self._lpteam = self.lp.people(self.teamname)
                   ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'people'
I, [2024-10-02T01:05:33.029140 #1]  INFO -- :


FAILED
--------------------
Pups::ExecError: add-apt-repository ppa:ondrej/php failed with return #<Process::Status: pid 3887 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in spawn'
exec failed with the params "add-apt-repository ppa:ondrej/php"
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
b74ec42509c5559c7814ad3011f49969bd7aba5fd92d2ba16717584dae2f9e4f
root@htd-9-feb-22-live:/var/discourse#

아래와 같이 파일을 8.2 php로 업데이트해 보았지만 여전히 오류가 발생합니다.

hooks:
  after_ssl:
    # mkdir tmp/amp_cache/
  - exec: apt-get update
  #- exec: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring
  #- exec: apt-get install -y php7.4-mbstring php7.4-xml
  # Install software-properties-common to add repositories
  - exec: apt-get install -y software-properties-common
  # Add the Ondřej Surý PPA for the latest PHP versions
  - exec: add-apt-repository -y ppa:ondrej/php
  - exec: apt-get update
  # Install the latest version of PHP and the required extensions
  - exec: apt-get install -y php8.2 php8.2-curl php8.2-fpm php8.2-mbstring php8.2-xml
  - exec: mkdir -p /run/php

  - replace:
      filename: "/etc/nginx/conf.d/discourse.conf"
      from: /gzip_proxied any;/
      to: |
        gzip_proxied any;
        ## BEGIN inserted by web.amp.template.ymly
        location /ads.txt {
          alias /shared/amp/ads.txt;
        }
        if ($arg_amp) { rewrite ^ /amp/index.php?q=$uri last; }

        location ~ \\.php\\$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          #fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          fastcgi_pass unix:/run/php/php8.2-fpm.sock;

        }

        location @amp {
          rewrite ^/amp(.*) /amp/index.php?q=$1;
        }
        
        location /custom_widgets.php {
          include         fastcgi_params;
          root  /shared/amp/api/;
          #fastcgi_pass    unix:/run/php/php7.4-fpm.sock;
          fastcgi_pass    unix:/run/php/php8.2-fpm.sock;
          fastcgi_param   SCRIPT_FILENAME  /shared/amp/api/custom_widgets.php;
          fastcgi_param   QUERY_STRING     $query_string;
          fastcgi_param   REQUEST_METHOD   $request_method;
          fastcgi_param   CONTENT_TYPE     $content_type;
          fastcgi_param   CONTENT_LENGTH   $content_length;
        }
        
        
        location /amp {
          index index.php;
          try_files $uri $uri/ @amp;
          alias /shared/amp;
          location ~ \\.php$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          #fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          fastcgi_pass unix:/run/php/php8.2-fpm.sock;

          }
        }
        ## END inserted by web.amp.template.ymly

  - file:
     path: /etc/service/phpfpm/run
     chmod: "+x"
     contents: |
        #!/bin/sh
        exec 2>&1
        #exec /usr/sbin/php-fpm7.4 --nodaemonize
        exec /usr/sbin/php-fpm8.2 --nodaemonize


  - file:
     path: /etc/runit/3.d/01-phpfpm
     chmod: "+x"
     contents: |
       #!/bin/bash
       sv stop phpfpm

아래와 같은 오류가 발생합니다.

Setting up packagekit (1.2.6-5) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of force-reload.
Failed to open connection to "system" message bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
Created symlink /etc/systemd/user/sockets.target.wants/pk-debconf-helper.socket → /usr/lib/systemd/user/pk-debconf-helper.socket.
Setting up packagekit-tools (1.2.6-5) ...
Setting up software-properties-common (0.99.30-4.1~deb12u1) ...
Processing triggers for dbus (1.14.10-1~deb12u1) ...

I, [2024-10-02T01:32:10.341970 #1]  INFO -- : > add-apt-repository -y ppa:ondrej/php
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 362, in <module>
    sys.exit(0 if addaptrepo.main() else 1)
                  ^^^^^^^^^^^^^^^^^
  File "/usr/bin/add-apt-repository", line 345, in main
    shortcut = handler(source, **shortcut_params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/shortcuts.py", line 40, in shortcut_handler
    return handler(shortcut, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 86, in __init__
    if self.lpppa.publish_debug_symbols:
       ^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 126, in lpppa
    self._lpppa = self.lpteam.getPPAByName(name=self.ppaname)
                  ^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/softwareproperties/ppa.py", line 113, in lpteam
    self._lpteam = self.lp.people(self.teamname)
                   ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'people'
I, [2024-10-02T01:32:10.554558 #1]  INFO -- :


FAILED
--------------------
Pups::ExecError: add-apt-repository -y ppa:ondrej/php failed with return #<Process::Status: pid 3885 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params "add-apt-repository -y ppa:ondrej/php"
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
8ec2386561b45752c20182c8f592036fa0921f1e81c3bd17b50c9ca2660a2354
root@htd-9-feb-22-live:/var/discourse#

제 원래 파일은 다음과 같았습니다.

hooks:
  after_ssl:
    # mkdir tmp/amp_cache/
  - exec: apt-get update
  - exec: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring
  - exec: apt-get install -y php7.4-mbstring php7.4-xml
  - exec: mkdir -p /run/php

  - replace:
      filename: "/etc/nginx/conf.d/discourse.conf"
      from: /gzip_proxied any;/
      to: |
        gzip_proxied any;
        ## BEGIN inserted by web.amp.template.ymly
        location /ads.txt {
          alias /shared/amp/ads.txt;
        }
        if ($arg_amp) { rewrite ^ /amp/index.php?q=$uri last; }

        location ~ \\.php\\$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        }

        location @amp {
          rewrite ^/amp(.*) /amp/index.php?q=$1;
        }
        
        location /custom_widgets.php {
          include         fastcgi_params;
          root  /shared/amp/api/;
          fastcgi_pass    unix:/run/php/php7.4-fpm.sock;
          fastcgi_param   SCRIPT_FILENAME  /shared/amp/api/custom_widgets.php;
          fastcgi_param   QUERY_STRING     $query_string;
          fastcgi_param   REQUEST_METHOD   $request_method;
          fastcgi_param   CONTENT_TYPE     $content_type;
          fastcgi_param   CONTENT_LENGTH   $content_length;
        }
        
        
        location /amp {
          index index.php;
          try_files $uri $uri/ @amp;
          alias /shared/amp;
          location ~ \\.php$ {
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $request_filename;
          fastcgi_pass unix:/run/php/php7.4-fpm.sock;
          }
        }
        ## END inserted by web.amp.template.ymly

  - file:
     path: /etc/service/phpfpm/run
     chmod: "+x"
     contents: |
        #!/bin/sh
        exec 2>&1
        exec /usr/sbin/php-fpm7.4 --nodaemonize

  - file:
     path: /etc/runit/3.d/01-phpfpm
     chmod: "+x"
     contents: |
       #!/bin/bash
       sv stop phpfpm

이 문제를 겪지 않고 AMP 템플릿으로 성공적으로 재빌드할 수 있도록 올바른 PHP 버전을 설치하는 올바른 방법을 알려주실 수 있나요?

아니요, 이는 Discourse에서 원래 지원되지 않았으며 완전히 사용자 정의된 기능입니다.

PHP 7.4는 이미 거의 3년 전에 지원이 종료되었으므로, 버전을 8.3 정도로 높이는 것이 좋을 것 같습니다.

PHP와 관련된 모든 로직을 별도의 컨테이너에 두고, /amp 요청만 해당 컨테이너로 프록시하도록 구성하는 것을 권장합니다.