ศูนย์คู่มือ Ruk-Com PaaS

คู่มือการพัฒนา Deploy และดูแล Application บนแพลตฟอร์ม

RUK-COM PAAS / APPLICATION SETTINGS

คู่มือ Multiple Domains for PHP สำหรับ การตั้งค่า Application

คู่มือนี้เรียบเรียงสำหรับ Ruk-Com PaaS หน้าจอและตัวเลือกอาจแตกต่างตามเวอร์ชันและสิทธิ์ของบัญชี

ตรวจสอบ Environment, Region, สิทธิ์บัญชี และสำรองค่าปัจจุบันก่อนดำเนินการกับระบบจริง

คู่มือภาษาไทย

คำสั่ง ชื่อเมนู พารามิเตอร์ และค่าตัวอย่างในกรอบ Code คงรูปแบบตามระบบเพื่อให้คัดลอกและตรวจสอบได้ถูกต้อง

การใช้หลายโดเมนช่วยให้คุณสามารถเพิ่มการใช้งานประสิทธิภาพและความสามารถในการปรับขนาดของแอปพลิเคชัน PHP ของคุณได้และแน่นอนว่าช่วยประหยัดเงินของคุณโดยไม่จำเป็นต้องตั้งค่าอินสแตนซ์แยกต่างหาก

มาดูวิธีเรียกใช้หลายโดเมนบนเซิร์ฟเวอร์แอปพลิเคชัน PHP เพื่อให้แอปพลิเคชัน PHP ของคุณปรับขนาดได้และมีประสิทธิภาพยิ่งขึ้น

  1. เข้าสู่ระบบบัญชี PaaS

  2. คลิกสร้าง Environmentที่มุมซ้ายบนของแดชบอร์ด

  3. ในตัวช่วยสร้างที่เปิดอยู่ให้ไปที่แท็บ PHP เลือกเซิร์ฟเวอร์แอปพลิเคชันและระบุจำนวนทรัพยากรที่แอปพลิเคชันของคุณต้องการหลังจากนั้นให้ป้อนชื่อ Environment แล้วคลิกสร้างปุ่ม.

Image 35: environment wizardภายในไม่กี่วินาที Environment ของคุณจะปรากฏบนแดชบอร์ดแพลตฟอร์ม

Image 36: PHP environment for multi domains4. คุณต้องมีชื่อใน DNS ซึ่งแก้ไขเป็นที่อยู่ IP ของคุณดังนั้นซื้อชื่อโดเมนสำหรับ Environment ของคุณสามารถทำได้สองวิธี: โดยการเพิ่มระเบียน CNAME หรือโดยการตั้งค่า A Records คุณสามารถอ่านเพิ่มเติมได้ที่นี่.

  1. หลังจากนั้นให้คลิกที่การตั้งค่าปุ่มสำหรับ Environment ของคุณและผูกโดเมนของคุณเป็นตัวอย่างที่เราใช้ URL ต่อไปนี้:mydomain.comและmyseconddomain.com.

Image 37: bind domain

บันทึก:ในกรณีนี้เราใส่รายการลงในไฟล์โฮสต์ของเราสำหรับการทดสอบในเครื่องและรายการจะทำงานจากเครื่องที่มีรายการโฮสต์เหล่านั้นเท่านั้น

  1. ตอนนี้คุณสามารถอัพโหลดได้แล้วซิปแพคเกจกับแอปของคุณไปยัง Deployment Manager และปรับใช้กับ Environment ที่คุณสร้างไว้ก่อนหน้านี้

Image 38: upload first applicationImage 39: upload second application7. เมื่อแอปพลิเคชันของคุณใช้งานได้สำเร็จคุณจะต้องระบุการกำหนดค่าโฮสต์เสมือนของคุณ

  • สำหรับอาปาเช่

คลิกการกำหนดค่าถัดจากเซิร์ฟเวอร์ Apache และเปิดไฟล์httpd.confไฟล์ (ในการประชุมไดเรกทอรี) ชุดโฮสต์เสมือนพารามิเตอร์สำหรับชื่อโดเมนสองชื่อแยกกันโดยการระบุเส้นทางไปยังบริบทที่ปรับใช้และชื่อของโดเมน:

คัดลอกอาปาเช่

Listen 80
<VirtualHost *:80>
    DocumentRoot /var/www/webroot/firstapp
    ServerName mydomain.com
    ...
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot /var/www/webroot/secondapp
    ServerName myseconddomain.com
    ...
</VirtualHost>

Image 40: Apache httpd conf*สำหรับ NGINX

คลิกการกำหนดค่าถัดจากเซิร์ฟเวอร์ NGINX และเปิดไฟล์nginx.confไฟล์ในการประชุมไดเรกทอรี

ระบุการตั้งค่าของคุณในเซิร์ฟเวอร์ปิดกั้น

  • server_name (โดเมนของคุณ)
  • ROOT (บริบทที่คุณระบุขณะปรับใช้)

โปรดทราบว่าคุณต้องมีแยกต่างหากเซิร์ฟเวอร์บล็อกด้วยการตั้งค่าของตัวเองสำหรับแต่ละโดเมนที่คุณผูกไว้

สำเนา nginx

server {
        listen       80;
        server_name  localhost;

include /etc/nginx/aliases.conf;
        location / {
            root   /var/www/webroot/ROOT;
            index  index.html index.htm index.php;

            location ~ \.php$ {
                location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot/ROOT$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot/ROOT;
            }

        }
        index  index.php index.html index.htm;

error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

location ~ /\. { deny all; access_log off; log_not_found off; }

location ~ \.php$ {
        location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot;
        }

    }

ในกรณีของเราการตั้งค่าจะเป็นดังนี้:

สำเนา nginx

server {
        listen       80;
        server_name  mydomain.com;

    include /etc/nginx/aliases.conf;
        location / {
            root   /var/www/webroot/firstapp;
            index  index.html index.htm index.php;

            location ~ \.php$ {
                location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot/firstapp$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot/firstapp;
            }

        }
        index  index.php index.html index.htm;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

            location ~ /\. { deny all; access_log off; log_not_found off; }

        location ~ \.php$ {
        location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot;
        }

    }

server {
        listen       80;
        server_name  myseconddomain.com;

            include /etc/nginx/aliases.conf;
        location / {
            root   /var/www/webroot/secondapp;
            index  index.html index.htm index.php;

            location ~ \.php$ {
                location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot/secondapp$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot/secondapp;
            }

        }
        index  index.php index.html index.htm;

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    location ~ /\. { deny all; access_log off; log_not_found off; }

    location ~ \.php$ {
        location ~ /\. { deny all; access_log off; log_not_found off; }
            include /etc/nginx/fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME /var/www/webroot$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
            fastcgi_param DOCUMENT_ROOT /var/www/webroot;
        }

    }

Image 41: NGINX nginx conf8. อย่าลืมบันทึกการเปลี่ยนแปลงและรีสตาร์ทแอปพลิเคชันเซิร์ฟเวอร์เพื่อใช้การตั้งค่าใหม่

Image 42: restart Apache9. ตอนนี้คุณสามารถตรวจสอบผลลัพธ์เพื่อให้แน่ใจว่าทุกอย่างทำงานได้อย่างถูกต้อง

Image 43: PHP application in browser

หวังว่าคำแนะนำนี้จะเป็นประโยชน์สำหรับคุณชื่อโดเมนเป็นส่วนสำคัญของข้อมูลประจำตัวออนไลน์ของคุณดังนั้นอย่าลืมปกป้องพวกเขาด้วย PaaS ใช้เวลาเพียงไม่กี่นาทีสนุก!