Multiple Domains for PHP
Running Multiple Domain Names on PHP Server
This approach improves application organisation and scalability while avoiding the need to create a separate server environment for every domain.
Create the PHP Environment
1Open the environment wizard
Sign in to the platform dashboard and click Create environment or New Environment.
2Select a PHP application server
Open the PHP tab, choose Apache PHP or NGINX PHP, configure the required resources, enter the environment name, and click Create.
After provisioning is complete, the new PHP environment appears in the dashboard.
Configure and Bind the Domains
Configure each domain in DNS so that it resolves to the environment. Depending on the networking setup, use a CNAME record or the required A record.
3Bind each custom domain
Open the environment Settings, select Custom Domains, enter the first domain, and click Bind. Repeat the process for the remaining domains.
Upload and Deploy the Applications
4Upload the first application
Open Deployment Manager, upload the first ZIP package, and deploy it to the PHP environment using a dedicated application context such as firstapp.
5Upload the second application
Upload the second package and deploy it to another context, for example secondapp.
Configure Multiple Domains on Apache PHP
6Open httpd.conf
Click Config beside the Apache PHP server and open /etc/httpd/conf/httpd.conf.
Create a separate <VirtualHost> definition for each domain and point its DocumentRoot to the matching application directory:
Listen 80
<VirtualHost *:80>
DocumentRoot /var/www/webroot/firstapp
ServerName mydomain.com
...
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/webroot/secondapp
ServerName myseconddomain.com
...
</VirtualHost>
ServerName
Enter the custom domain assigned to the application.
DocumentRoot
Enter the absolute path to the matching deployment context.
Configure Multiple Domains on NGINX PHP
7Open nginx.conf
Click Config beside the NGINX PHP server and open the main NGINX configuration file in the conf directory.
Create a separate server block for every bound domain. Define the domain with server_name and point the root and FastCGI paths to the matching application context.
server {
listen 80;
server_name mydomain.com;
root /var/www/webroot/firstapp;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
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 DOCUMENT_ROOT
/var/www/webroot/firstapp;
}
}
server {
listen 80;
server_name myseconddomain.com;
root /var/www/webroot/secondapp;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
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 DOCUMENT_ROOT
/var/www/webroot/secondapp;
}
}
Restart and Verify
8Save and restart the server
Save the configuration and restart the Apache PHP or NGINX PHP node.
Open each custom domain in a browser. Every domain should load the application assigned to its document root.
