mercredi 26 août 2020

Multiple Domain in single VPS using VHOST

I want to create multiple sites in one vps, example sites on port 80 use www.domain1.com and on port 8080 use www.domain2.com. can nginx or anything handle that?

i have tried to use port forwarding, but is not working well

my nginx.conf

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  domain1.com;
        root          /var/www/html;

        # Load configuration files for the default server block.
        #include /etc/nginx/default.d/*.conf;

        location / {
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

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

        # PHP
            location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

        }

    }

and my virtualhost.conf

#Virual Host
    server {
         listen 8080;

         access_log /var/log/nginx/nginx-access.log;
         error_log /var/log/nginx/nginx-error.log;

        # Root
         root /var/www/web2/public;
         index index.php index.html index.htm;

         # server name
         server_name domain2.com;

         location / {
                try_files $uri $uri/ /index.php?$query_string;
         }

         # PHP
         location ~ \.php$ {
                 try_files $uri =404;
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
                 fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
                 fastcgi_index index.php;
                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                 include fastcgi_params;

         }

  }

if possible, how the way?




Aucun commentaire:

Enregistrer un commentaire