A
A
Andrey Silaev2015-02-19 04:48:22
PHP
Andrey Silaev, 2015-02-19 04:48:22

How to set up a server for a website builder?

Hello.
I solved this problem on ISPmanager a long time ago, but now I don't remember how to do it.
In general, the idea is this, on the server (VDS) we create a site that processes the SERVER_NAME variable and displays the desired site by domain.
Task: so that any domain or subdomain is automatically sent to this site, and then the php script will figure out what to display.
Those. in the site builder, someone created a site on a subdomain, and it immediately became attached to the user. Then he added the domain in the admin panel and this domain starts to resolve on the server. Here's what to do.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Arman, 2015-02-19
@Arik

1. If I'm not mistaken, then you don't need SERVER_NAME, but HTTP_HOST.
2. In the domain panel, make two entries, without `, do not forget the dots at the end:
A-record `site.com.` `11.11.11.11` - (IP server)
CNAME-record `*.site.com.` ` site.com` — treat all subdomains as site.com. give ip of your server
3. Nginx, something like this

server {
    listen 80;
    server_name www.site.com;
    return 301  http://site.com$request_uri;
}

server {
    listen 80 default_server;
    server_name site.com *.site.com;
    root /var/www;
    index index.php index.html index.htm;
...
}

N
Nazar Mokrinsky, 2015-02-19
@nazarpc

If no virtual host works, the default host will work (default, comes out of the box, just set the DNS record * to the same IP, all subdomains will come to you), apparently just what you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question