Multiple Domains for PHP

Running Multiple Domain Names on PHP Server

A single PHP application-server environment can serve several applications through different custom domain names. Each domain is connected to its own application directory through Apache virtual-host or NGINX server-block settings.

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.

Create a PHP environment
Select the PHP application server and configure the environment resources.

After provisioning is complete, the new PHP environment appears in the dashboard.

PHP environment for multiple domains
The PHP environment is ready for domain binding and application deployment.

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.

Bind multiple custom domains
Bind all required custom domains to the same PHP environment.
For local testing, domain records can be added to the computer’s hosts file. Such mappings work only on the machine where the hosts file was modified.

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.

Upload the first PHP application
Upload and deploy the first application package.

5Upload the second application

Upload the second package and deploy it to another context, for example secondapp.

Upload the second PHP application
Use a separate application context for the second domain.
Context mapping: The folder or deployment context used for each application must match the document root configured for its domain.

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.
Apache virtual-host configuration
Add a separate Apache virtual host for every domain.

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;
    }
}
Keep the platform’s existing NGINX include statements, security locations, aliases, error pages, and FastCGI parameters when adapting the configuration. Change only the domain and application-path values required for each server block.
Configuration safety: Create a backup before editing Apache or NGINX configuration files. A syntax error can prevent the web server from restarting.

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.

For secure access, install an SSL certificate that covers every domain or configure separate certificates through the supported platform SSL workflow.

What’s next?