How to set multiple domain names on 1 nginx server ?

Posted 1 week ago by vansunet

Hello, I installed nginx under new ubuntu 18 installation under AWS and I want to make multiple domain names on 1 server. Fot this

I created at freenom new hosting and with whatsmydns service I check that it is resolved ok: I installed nginx with "Welcome to nginx!" greeting page by url

Created /var/www/ file with text File /var/www/ index

I created file /etc/nginx/sites-available/ with text: pstream votes-backend { # Lets you define a group of servers server unix:/var/run/php7.2-fpm.sock; }

server { listen 80;

root /var/www/; index index.php;


We keep this block, because it doesn't make sense to pass

everything to PHP.

location / { # try_files $uri $uri/ =404; try_files $uri $uri/ /index.php index.php;


location ~ .php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; # this defines a regular expression to separate the SCRIPT_FILENAME and PATH_INFO for later use try_files $uri =404; # OR Set cgi.fix_pathinfo=0 in php.ini (for security) fastcgi_pass votes-backend; # OR unix:/var/run/php7.2-fpm.sock OR fastcgi_index index.php; # appends index.php to a URI ending with a slash include fastcgi_params; }

} editied /etc/hosts (I am not sure if i have to edit it): localhost localhost created symbol link : sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ restart nginx service and php: sudo service nginx restart sudo systemctl restart php7.2-fpm Check The Syntax Of nginx Files sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful check that /etc/nginx/nginx.conf has links to /etc/nginx/sites-enabled/: user www-data; worker_processes auto; pid /run/; include /etc/nginx/modules-enabled/*.conf;

events { worker_connections 768; # multi_accept on; }

http {

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

} but running in browser I got 404 error also running curl in console of my server I got empty line, but I expected content of my /var/www/ file?

What is wrong and how to fix it ?


Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.