คู่มือ Multiple Domains for PHP สำหรับ การตั้งค่า Application
คู่มือนี้เรียบเรียงสำหรับ Ruk-Com PaaS หน้าจอและตัวเลือกอาจแตกต่างตามเวอร์ชันและสิทธิ์ของบัญชี
ตรวจสอบ Environment, Region, สิทธิ์บัญชี และสำรองค่าปัจจุบันก่อนดำเนินการกับระบบจริง
คำสั่ง ชื่อเมนู พารามิเตอร์ และค่าตัวอย่างในกรอบ Code คงรูปแบบตามระบบเพื่อให้คัดลอกและตรวจสอบได้ถูกต้อง
การใช้หลายโดเมนช่วยให้คุณสามารถเพิ่มการใช้งานประสิทธิภาพและความสามารถในการปรับขนาดของแอปพลิเคชัน PHP ของคุณได้และแน่นอนว่าช่วยประหยัดเงินของคุณโดยไม่จำเป็นต้องตั้งค่าอินสแตนซ์แยกต่างหาก
มาดูวิธีเรียกใช้หลายโดเมนบนเซิร์ฟเวอร์แอปพลิเคชัน PHP เพื่อให้แอปพลิเคชัน PHP ของคุณปรับขนาดได้และมีประสิทธิภาพยิ่งขึ้น
-
เข้าสู่ระบบบัญชี PaaS
-
คลิกสร้าง Environmentที่มุมซ้ายบนของแดชบอร์ด
-
ในตัวช่วยสร้างที่เปิดอยู่ให้ไปที่แท็บ PHP เลือกเซิร์ฟเวอร์แอปพลิเคชันและระบุจำนวนทรัพยากรที่แอปพลิเคชันของคุณต้องการหลังจากนั้นให้ป้อนชื่อ Environment แล้วคลิกสร้างปุ่ม.
ภายในไม่กี่วินาที Environment ของคุณจะปรากฏบนแดชบอร์ดแพลตฟอร์ม
4. คุณต้องมีชื่อใน DNS ซึ่งแก้ไขเป็นที่อยู่ IP ของคุณดังนั้นซื้อชื่อโดเมนสำหรับ Environment ของคุณสามารถทำได้สองวิธี: โดยการเพิ่มระเบียน CNAME หรือโดยการตั้งค่า A Records คุณสามารถอ่านเพิ่มเติมได้ที่นี่.
- หลังจากนั้นให้คลิกที่การตั้งค่าปุ่มสำหรับ Environment ของคุณและผูกโดเมนของคุณเป็นตัวอย่างที่เราใช้ URL ต่อไปนี้:mydomain.comและmyseconddomain.com.
บันทึก:ในกรณีนี้เราใส่รายการลงในไฟล์โฮสต์ของเราสำหรับการทดสอบในเครื่องและรายการจะทำงานจากเครื่องที่มีรายการโฮสต์เหล่านั้นเท่านั้น
- ตอนนี้คุณสามารถอัพโหลดได้แล้วซิปแพคเกจกับแอปของคุณไปยัง Deployment Manager และปรับใช้กับ Environment ที่คุณสร้างไว้ก่อนหน้านี้

7. เมื่อแอปพลิเคชันของคุณใช้งานได้สำเร็จคุณจะต้องระบุการกำหนดค่าโฮสต์เสมือนของคุณ
- สำหรับอาปาเช่
คลิกการกำหนดค่าถัดจากเซิร์ฟเวอร์ 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>
คลิกการกำหนดค่าถัดจากเซิร์ฟเวอร์ 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;
}
}
8. อย่าลืมบันทึกการเปลี่ยนแปลงและรีสตาร์ทแอปพลิเคชันเซิร์ฟเวอร์เพื่อใช้การตั้งค่าใหม่
9. ตอนนี้คุณสามารถตรวจสอบผลลัพธ์เพื่อให้แน่ใจว่าทุกอย่างทำงานได้อย่างถูกต้อง
หวังว่าคำแนะนำนี้จะเป็นประโยชน์สำหรับคุณชื่อโดเมนเป็นส่วนสำคัญของข้อมูลประจำตัวออนไลน์ของคุณดังนั้นอย่าลืมปกป้องพวกเขาด้วย PaaS ใช้เวลาเพียงไม่กี่นาทีสนุก!


