Tentativo di includere PHP 7 nel contenitore Discourse

Sto cercando di aggiornare discourse ma fallisce con questo comando

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: Il pacchetto 'php7.4' non ha un candidato all'installazione
E: Impossibile trovare il pacchetto php7.4-curl
E: Impossibile trovare alcun pacchetto tramite glob 'php7.4-curl'
E: Impossibile trovare alcun pacchetto tramite regex 'php7.4-curl'
E: Il pacchetto 'php7.4-fpm' non ha un candidato all'installazione
E: Impossibile trovare il pacchetto php7.4-mbstring
E: Impossibile trovare alcun pacchetto tramite glob 'php7.4-mbstring'
E: Impossibile trovare alcun pacchetto tramite regex 'php7.4-mbstring'
I, [2024-10-01T23:08:47.335246 #1]  INFO -- : Lettura degli elenchi dei pacchetti...
Costruzione dell'albero delle dipendenze...
Lettura delle informazioni sullo stato...
Il pacchetto php7.4 non è disponibile, ma è referenziato da un altro pacchetto.
Ciò potrebbe significare che il pacchetto manca, è stato deprecato, o
è disponibile solo da un'altra fonte

Il pacchetto php7.4-fpm non è disponibile, ma è referenziato da un altro pacchetto.
Ciò potrebbe significare che il pacchetto manca, è stato deprecato, o
è disponibile solo da un'altra fonte


FALLITO
--------------------
Pups::ExecError: apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring è fallito con ritorno #<Process::Status: pid 2912 exit 100>
Posizione del fallimento: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in spawn'
exec fallito con i parametri "apt-get install -y php7.4 php7.4-curl php7.4-fpm php7.4-mbstring"
bootstrap fallito con codice di uscita 100
** IMPOSSIBILE EFFETTUARE IL BOOTSTRAP ** si prega di scorrere verso l'alto e cercare messaggi di errore precedenti, potrebbero essercene piĂą di uno.
./discourse-doctor potrebbe aiutare a diagnosticare il problema.
d87ce61f0dbfc527ede7d3c09e222eff42934608174066401b2317d05193786b
root@htd-9-feb-22-live:/var/discourse#

Discourse è installato usando NGINX interno.
Quindi sto cercando di aggiornare discourse che ha 2 anni. da 3.2 a 3.4 credo.

Quindi ho eseguito i seguenti comandi

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

Il file YAML è simile a questo, ho rimosso le informazioni personali:

# IMPORTANTE: IMPOSTA UNA PASSWORD SEGRETA in Postgres per l'utente Discourse
# TODO: cambia SOME_SECRET in questo 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"
  ## Decommenta queste due righe se desideri aggiungere Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"

## quali porte TCP/IP dovrebbe esporre questo container?
## Se vuoi che Discourse condivida una porta con un altro webserver come Apache o nginx,
## vedi https://meta.discourse.org/t/17247 per i dettagli
expose:
  - "80:80" # http
  - "443:443" # https

# Usa la chiave 'links' per collegare i container, ovvero usa il flag Docker --link.
links:
  - link:
      name: data
      alias: data

# argomenti aggiuntivi per Docker?
# docker_args:

params:
  ## Quale revisione Git dovrebbe usare questo container? (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
  # Limiti globali di richieste che disabilitano i limiti di richieste per consentire al SEO di correggere il penalizzante crawling per eliminare l'errore 429 troppo molte richieste
  DISCOURSE_MAX_REQS_PER_IP_MODE: none

  ## Quante richieste web concorrenti sono supportate? Dipende da memoria e core CPU.
  ## verrĂ  impostato automaticamente da bootstrap in base alle CPU rilevate, o puoi sovrascriverlo
  UNICORN_WORKERS: 32

  ## TODO: Il nome del dominio a cui risponderĂ  questa istanza di Discourse
  #DISCOURSE_HOSTNAME: hidden
  DISCOURSE_HOSTNAME:hidden

  ## Decommenta se vuoi che il container venga avviato con lo stesso
  ## hostname (-h opzione) specificato sopra (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: Elenco di email separate da virgole che diventeranno amministratori e sviluppatori
  ## alla prima registrazione, ad esempio 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: "hidden"

  ## TODO: Il server di posta SMTP utilizzato per convalidare i nuovi account e inviare notifiche
  # INDIRIZZO SMTP, nome utente e password sono richiesti
  # ATTENZIONE il carattere '#' nella password SMTP può causare problemi!
  DISCOURSE_SMTP_ADDRESS: hidden
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: hidden
  DISCOURSE_SMTP_PASSWORD: "hidden"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (opzionale, default true)
  DISCOURSE_SMTP_DOMAIN: hidden
  DISCOURSE_NOTIFICATION_EMAIL: hidden

  ## Se hai aggiunto il template Lets Encrypt, decommenta sotto per ottenere un certificato SSL gratuito
  LETSENCRYPT_ACCOUNT_EMAIL: hidden
  ## TODO: configurare la connettivitĂ  ai database
  #ljlsdfj;sdfj;lkdsfj
  DISCOURSE_DB_SOCKET: ""
  #DISCOURSE_DB_USERNAME: hidden
  DISCOURSE_DB_PASSWORD: hidden
  DISCOURSE_DB_HOST: data
  DISCOURSE_REDIS_HOST: data

  ## L'indirizzo CDN http o https per questa istanza di Discourse (configurato per il pull)
  ## vedi https://meta.discourse.org/t/14857 per i dettagli


  ## La chiave API di Maxmind geolocation per la ricerca dell'indirizzo IP
  ## vedi https://meta.discourse.org/t/-/137387/23 per i dettagli


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

## I plugin vanno qui
## vedi https://meta.discourse.org/t/19157 per i dettagli
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 # plugin personalizzato per il supporto matematico JAX
          #- git clone https://github.com/discourse/discourse-solved.git # plugin personalizzato per domande e risposte e scelta della migliore risposta
          #- git clone https://github.com/discourse/discourse-voting.git # plugin personalizzato per votare solo sugli argomenti
          #- git clone https://github.com/discourse/discourse-yearly-review.git # plugin personalizzato per pubblicare automaticamente un argomento annuale di attivitĂ  del forum
          #- git clone https://github.com/discourse/discourse-user-notes.git # plugin personalizzato per consentire allo staff di aggiungere note su un utente
          #- git clone https://github.com/paviliondev/discourse-question-answer.git # plugin personalizzato non ufficiale per votare sui post in stile SO
          #- git clone https://github.com/discourse/discourse-adplugin.git # plugin ufficiale personalizzato per annunci
          #- git clone https://github.com/discourse/discourse-whos-online.git # plugin personalizzato per vedere chi è online
          #- git clone https://github.com/paviliondev/discourse-topic-previews.git # plugin personalizzato per mostrare le anteprime degli argomenti in modo gradevole
          #- git clone https://github.com/paviliondev/discourse-ratings.git # plugin personalizzato per consentire la valutazione degli argomenti da parte degli utenti
          #- git clone https://github.com/discourse/discourse-cakeday.git # plugin ufficiale per celebrazioni di compleanni e date di iscrizione
          #- git clone https://github.com/discourse/discourse-saved-searches.git # plugin ufficiale per notifiche di ricerche salvate
          #- git clone https://github.com/paviliondev/discourse-follow.git # plugin personalizzato per consentire agli utenti di seguirsi a vicenda
          - git clone https://github.com/FaizanZahid/discourse-amp-htd-plugin.git # build personalizzato supporto AMP per HTD
          #- git clone https://github.com/discourse/discourse-assign.git # personalizzato per assegnare argomenti allo staff
          #- git clone https://github.com/paviliondev/x-discourse-tlp-thumbnail.git # plugin personalizzato per mostrare miniature da immagini CDN
          #- git clone https://github.com/discourse/discourse-prometheus.git # plugin personalizzato per il monitoraggio della bassa velocitĂ 
          #- git clone https://github.com/discourse/discourse-push-notifications.git # plugin per notifiche push

## Ricorda, questa è sintassi YAML - puoi avere solo un blocco con un nome worker_conn era 3000
run:
  - exec: echo "Inizio dei comandi personalizzati"
  - 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"

  ## Se vuoi configurare il login con password per root, decommenta e cambia:
  ## Usa solo una delle seguenti righe:
  #- exec: /usr/sbin/usermod -p 'PASSWORD_HASH' root
  #- exec: /usr/sbin/usermod -p "$(mkpasswd -m sha-256 'RAW_PASSWORD')" root

  ## Se vuoi autorizzare utenti aggiuntivi, decommenta e cambia:
  #- exec: ssh-import-id username
  #- exec: ssh-import-id anotherusername

  - exec: echo "Fine dei comandi personalizzati"
  - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Chiavi SSH autorizzate per questo container:"; } NF>=2 {print $NF;}'

Qualcuno può aiutarmi a risolverlo dato che il mio sito è ora offline?

Stavo anche pensando di fare

./launcher rebuild data

Non c’è nginx e PHP installati sul mio server, questo significa che sta usando nginx interno e PHP interno. Quindi cosa devo fare per risolverlo e aggiornare il mio discourse e il container dei dati?

Rimuovi questa riga qui.

Grazie @Falco .. Sì, l’ho commentato e funziona bene, ma ho bisogno che le pagine AMP funzionino con lo script sottostante, quindi devo aggiornarlo qui per farlo funzionare con l’ultima versione di PHP? Perché se commento il template AMP, le pagine AMP non funzioneranno.

Di seguito c’è 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

Quali modifiche devo apportare lì?

Se faccio

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

ottengo gli errori seguenti

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#

Ho provato ad aggiornare il file alla versione PHP 8.2 come mostrato sotto, ma ottengo ancora errori

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

Sto ricevendo l’errore seguente

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#

Il mio file originale era

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

Puoi gentilmente indicarmi il modo corretto per installare la versione corretta di PHP per non affrontare questo problema e poter ricostruire con successo con il template AMP?

Non proprio, poiché questo non è mai stato supportato da Discourse ed è qualcosa di completamente personalizzato.

PHP 7.4 ha raggiunto la fine del suo ciclo di vita quasi tre anni fa, quindi sospetto che potresti voler aumentare quel numero di versione a qualcosa come 8.3.

Suggerisco di mantenere PHP e tutta la logica associata in un container separato e di inoltrare tutto ciò che è in /amp ad esso.