[مدفوع] تثبيت Discourse في مجلد فرعي على خادم Ubuntu

لدينا موقع هذا. نحتاج إلى إعداد منتدى discourse في مجلد فرعي باستخدام docker على نظام ubuntu. نريد تشغيل discourse على TalkWithStranger Ask - Ask and chat random strangers and meet new people in online free chat rooms. دون استخدام CDN.

لقد حاولت إعداده باتباع هذا الدليل، لكنني واجهت المشاكل التالية:

  1. تختفي الصور الرمزية (Avatars) بعد عمليتي إعادة بناء أو ثلاث.
  2. تظهر الصور المرفوعة في المواضيع رسالة خطأ 404 بعد بعض عمليات إعادة البناء.

يجب عليك إصلاح الأخطاء في نطاق الاختبار هذا حتى أتمكن من تثبيتها وإصلاح نفس الأخطاء على موقعي الحي. تم إنجاز 95% من العمل، كل ما عليك فعله هو إصلاح بعض الأخطاء.

ملف app.yml الخاص بي

##   دعم المجلدات الفرعية مع Docker   https://meta.discourse.org/t/subfolder-support-with-docker/30507

## قالب تكوين discourse-terraform Docker

##

## بعد إجراء أي تعديلات على هذا الملف، يجب عليك إعادة البناء

## لكي تنعكس التغييرات على نسخة Discourse المباشرة:

##

## /var/discourse/launcher rebuild app

##

## هذا هو قالب حاوية Docker Discourse الشاملة والمستقلة

# يمكنك إضافة حد للسرعة (rate limiting) عن طريق تعليق قالب ratelimited.

# افتراضيًا، يسمح بـ 12 طلبًا في الثانية لكل عنوان IP، و 100 طلب في الدقيقة لكل عنوان IP.

# يمكن تكوين ذلك عن طريق تعديل المعاملات في هذا الملف.

templates:

  - "templates/postgres.template.yml"

  - "templates/redis.template.yml"

  - "templates/web.template.yml"

  - "templates/sshd.template.yml"

## أي منافذ TCP/IP يجب أن تعرضها هذه الحاوية؟

expose:

  - "1357:80" # غيّر هذا المنفذ إلى المنفذ الذي تريد تشغيل discourse عليه # تحويل منفذ المضيف 80 إلى منفذ الحاوية 80 (http)

  #- "2222:22" # تحويل منفذ المضيف 2222 إلى منفذ الحاوية 22 (ssh)

params:

  db_default_text_search_config: "pg_catalog.english"

  ## قم بتعيين db_shared_buffers إلى ثلث الذاكرة التي تريد تخصيصها لـ postgres

  ## في تثبيت 1 جيجابايت، اضبطه على 128 ميجابايت، وفي مثيل 4 جيجابايت يمكنك رفعه إلى 1 جيجابايت

  db_shared_buffers: "512MB"

  #

  ## أي إصدار Git يجب أن تستخدمه هذه الحاوية؟ (الافتراضي: tests-passed)

  #version: tests-passed

env:

  LANG: en_US.UTF-8

  ## TODO: كم عدد طلبات الويب المتزامنة المدعومة؟

  ## مع 2 جيجابايت نوصي بـ 3-4 عمال، ومع 1 جيجابايت فقط 2

  UNICORN_WORKERS: 3

  ##

  ## TODO: قائمة عناوين البريد الإلكتروني المفصولة بفواصل التي سيتم تعيينها كمسؤول ومطور

  ## مثال عند التسجيل الأولي: 'user1@example.com, user2@example.com'

  DISCOURSE_DEVELOPER_EMAILS: "ahmeds.works@gmail.com" # غيّر هذه العناوين إلى عناوين البريد الإلكتروني لمسؤولي الموقع

  ##

  ## TODO: اسم النطاق الذي ستستجيب له هذه النسخة من Discourse

  DISCOURSE_RELATIVE_URL_ROOT: /ask 

  DISCOURSE_HOSTNAME: "privitevps.ga" # غيّر هذا النطاق إلى نطاق موقعك

  ##

  ## TODO: خادم البريد الذي ستستخدمه هذه النسخة من Discourse

  # غيّر إعدادات SMTP إلى إعداداتك الخاصة

  DISCOURSE_SMTP_ADDRESS: smtp.example.com

  DISCOURSE_SMTP_PORT: 587

  DISCOURSE_SMTP_USER_NAME: example@example.com

  DISCOURSE_SMTP_PASSWORD: example_password

##

  ## عنوان CDN لهذه النسخة من Discourse (مُهيأ للسحب من)

  #DISCOURSE_CDN_URL: //discourse-cdn.example.com

## هذه الحاويات لا تحتفظ بحالة، ويتم تخزين جميع البيانات في /shared

volumes:

  - volume:

      host: /var/discourse/shared/standalone

      guest: /shared

  - volume:

      host: /var/discourse/shared/standalone/log/var-log

      guest: /var/log

## يسمح لك ملحق مدير Docker بترقية Discourse بنقرة واحدة

## http://discourse.example.com/admin/docker

hooks:

  after_code:

    - exec:

        cd: $home/plugins

        cmd:

          - mkdir -p plugins

          - git clone https://github.com/discourse/docker_manager.git

          - git clone https://github.com/discourse/discourse-voting.git

## تذكر، هذا هو بناء جملة YAML - لا يمكن أن يكون لديك سوى كتلة واحدة باسم

run:

    - exec:

        cd: $home

        cmd:

          - rm -fr public/assets

          - sudo -E -u discourse bundle exec rake assets:precompile

          - mkdir -p public/ask

          - cd public/ask && ln -s ../uploads && ln -s ../backups

          - rm public/uploads

          - rm public/backups

    - replace:

       global: true

       filename: /etc/nginx/conf.d/discourse.conf

       from: proxy_pass http://discourse;

       to: |

          rewrite ^/(.*)$ /ask/$1 break;

          proxy_pass http://discourse;

    - replace:

       filename: /etc/nginx/conf.d/discourse.conf

       from: etag off;

       to: |

          etag off;

          location /ask {

             rewrite ^/ask/?(.*)$ /$1;

          }

    - replace:

         filename: /etc/nginx/conf.d/discourse.conf

         from: $proxy_add_x_forwarded_for

         to: $http_fastly_client_ip

         global: true

    - exec: echo "نهاية الأوامر المخصصة"

    - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "مفاتيح SSH المصرح بها لهذه الحاوية:"; } NF>=2 {print $NF;}'

إعدادات nginx

location /ask {
    proxy_pass      http://localhost:1357;
    proxy_read_timeout      90;
    proxy_redirect  http://localhost:1357 https://privitevps.ga;
}

سجل أخطاء Discourse

    /var/www/discourse/app/models/report.rb:267:in `rescue in find'

    /var/www/discourse/app/models/report.rb:234:in `find'

    /var/www/discourse/app/controllers/admin/reports_controller.rb:42:in `block (2 levels) in bulk'

    actionpack-6.0.3.5/lib/action_controller/metal/strong_parameters.rb:345:in `block in each_pair'

    actionpack-6.0.3.5/lib/action_controller/metal/strong_parameters.rb:344:in `each_pair'

    actionpack-6.0.3.5/lib/action_controller/metal/strong_parameters.rb:344:in `each_pair'

    /var/www/discourse/app/controllers/admin/reports_controller.rb:31:in `block in bulk'

    /var/www/discourse/lib/hijack.rb:56:in `instance_eval'

    /var/www/discourse/lib/hijack.rb:56:in `block in hijack'

    /var/www/discourse/lib/scheduler/defer.rb:94:in `block in do_work'

    rails_multisite-2.5.0/lib/rails_multisite/connection_management.rb:76:in `with_connection'

    /var/www/discourse/lib/scheduler/defer.rb:89:in `do_work'

    /var/www/discourse/lib/scheduler/defer.rb:79:in `block (2 levels) in start_thread'

سجل PostgreSQL

2021-04-01 18:33:04.209 UTC [51] LOG:  starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-01 18:33:04.210 UTC [51] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-04-01 18:33:04.211 UTC [51] LOG:  listening on IPv6 address "::", port 5432
2021-04-01 18:33:04.211 UTC [51] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-01 18:33:04.223 UTC [73] LOG:  database system was shut down at 2021-04-01 18:32:19 UTC
2021-04-01 18:33:04.230 UTC [51] LOG:  database system is ready to accept connections
2021-04-01 18:44:16.543 UTC [1155] discourse@discourse LOG:  provided user name (discourse) and authenticated user name (root) do not match
2021-04-01 18:44:16.544 UTC [1155] discourse@discourse FATAL:  Peer authentication failed for user "discourse"
2021-04-01 18:44:16.544 UTC [1155] discourse@discourse DETAIL:  Connection matched pg_hba.conf line 94: "local   all             all                                     peer"
2021-04-02 03:33:33.893 UTC [36640] discourse@discourse LOG:  duration: 141.998 ms  statement: COPY public.stylesheet_cache (id, target, digest, content, created_at, updated_at, theme_id, source_map) TO stdout;
2021-04-02 17:49:50.676 UTC [92100] discourse@discourse LOG:  duration: 156.461 ms  statement: DO $$DECLARE row record;
        BEGIN
          -- create <destination> schema if it does not exists already
          -- NOTE: DROP & CREATE SCHEMA is easier, but we don't want to drop the public schema
          -- otherwise extensions (like hstore & pg_trgm) won't work anymore...
          CREATE SCHEMA IF NOT EXISTS backup;
          -- move all <source> tables to <destination> schema
          FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'public'  AND tableowner = 'discourse'
          LOOP
            EXECUTE 'DROP TABLE IF EXISTS backup.' || quote_ident(row.tablename) || ' CASCADE;';
            EXECUTE 'ALTER TABLE public.' || quote_ident(row.tablename) || ' SET SCHEMA backup;';
          END LOOP;
          -- move all <source> views to <destination> schema
          FOR row IN SELECT viewname FROM pg_views WHERE schemaname = 'public' AND viewowner = 'discourse'
          LOOP
            EXECUTE 'DROP VIEW IF EXISTS backup.' || quote_ident(row.viewname) || ' CASCADE;';
            EXECUTE 'ALTER VIEW public.' || quote_ident(row.viewname) || ' SET SCHEMA backup;';
          END LOOP;
        END$$;

2021-04-02 17:49:52.092 UTC [92128] discourse@discourse LOG:  duration: 114.918 ms  statement: COPY public.scheduler_stats (id, name, hostname, pid, duration_ms, live_slots_start, live_slots_finish, started_at, success, error) FROM stdin;
2021-04-02 17:49:53.398 UTC [92128] discourse@discourse LOG:  duration: 1266.208 ms  statement: COPY public.stylesheet_cache (id, target, digest, content, created_at, updated_at, theme_id, source_map) FROM stdin;
2021-04-02 17:51:24.451 UTC [51] LOG:  received smart shutdown request
2021-04-02 17:51:26.828 UTC [51] LOG:  background worker "logical replication launcher" (PID 79) exited with exit code 1
2021-04-02 17:51:26.836 UTC [74] LOG:  shutting down
2021-04-02 17:51:26.948 UTC [51] LOG:  database system is shut down
2021-04-02 18:00:56.877 UTC [52] LOG:  starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-02 18:00:56.879 UTC [52] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-04-02 18:00:56.879 UTC [52] LOG:  listening on IPv6 address "::", port 5432
2021-04-02 18:00:56.880 UTC [52] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-02 18:00:56.893 UTC [73] LOG:  database system was shut down at 2021-04-02 18:00:11 UTC
2021-04-02 18:00:56.909 UTC [52] LOG:  database system is ready to accept connections
2021-04-02 18:03:23.275 UTC [343] discourse@discourse LOG:  duration: 172.267 ms  statement: UPDATE "stylesheet_cache"
           SET "content" = REPLACE("content", '/uploads', '/../uploads'), "digest" = REPLACE("digest", '/uploads', '/../uploads'), "source_map" = REPLACE("source_map", '/uploads', '/../uploads'), "target" = REPLACE("target", '/uploads', '/../uploads')
         WHERE "content" IS NOT NULL AND "content" LIKE '%/uploads%' OR "digest" IS NOT NULL AND "digest" LIKE '%/uploads%' OR "source_map" IS NOT NULL AND "source_map" LIKE '%/uploads%' OR "target" IS NOT NULL AND "target" LIKE '%/uploads%'

2021-04-02 18:03:55.952 UTC [52] LOG:  received smart shutdown request
2021-04-02 18:03:57.185 UTC [52] LOG:  background worker "logical replication launcher" (PID 79) exited with exit code 1
2021-04-02 18:03:57.189 UTC [74] LOG:  shutting down
2021-04-02 18:03:57.308 UTC [52] LOG:  database system is shut down
2021-04-02 18:04:00.354 UTC [47] LOG:  starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-02 18:04:00.355 UTC [47] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-04-02 18:04:00.356 UTC [47] LOG:  listening on IPv6 address "::", port 5432
2021-04-02 18:04:00.359 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-02 18:04:00.375 UTC [66] LOG:  database system was shut down at 2021-04-02 18:03:57 UTC
2021-04-02 18:04:00.380 UTC [47] LOG:  database system is ready to accept connections
2021-04-02 18:13:27.137 UTC [47] LOG:  received smart shutdown request
2021-04-02 18:13:27.980 UTC [47] LOG:  background worker "logical replication launcher" (PID 72) exited with exit code 1
2021-04-02 18:13:27.982 UTC [67] LOG:  shutting down
2021-04-02 18:13:28.009 UTC [47] LOG:  database system is shut down
2021-04-02 18:13:31.497 UTC [45] LOG:  starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
2021-04-02 18:13:31.499 UTC [45] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-04-02 18:13:31.499 UTC [45] LOG:  listening on IPv6 address "::", port 5432
2021-04-02 18:13:31.500 UTC [45] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-04-02 18:13:31.515 UTC [67] LOG:  database system was shut down at 2021-04-02 18:13:27 UTC
2021-04-02 18:13:31.520 UTC [45] LOG:  database system is ready to accept connections

سجل أخطاء Nginx

2021/04/02 18:01:06 [error] 69#69: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: _, request: "GET /ask/ HTTP/1.0", upstream: "http://127.0.0.1:3000/ask/", host: "localhost:1357"
2021/04/02 18:13:38 [error] 64#64: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: _, request: "POST /ask/message-bus/c734a550b6e54923aff3e0c6fdf1b014/poll HTTP/1.0", upstream: "http://127.0.0.1:3000/ask/message-bus/c734a550b6e54923aff3e0c6fdf1b014/poll", host: "localhost:1357", referrer: "https://privitevps.ga/ask/latest"

متى تحتاج إلى إنجازه؟

في أقرب وقت ممكن (ASAP)

ما هو ميزانيتك بالدولار الأمريكي التي يمكنك تقديمها لهذه المهمة؟

منفتح على الاقتراحات. يرجى إرسال رسالة خاصة لي مع نهجك وتقديرك.

إعجاب واحد (1)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.