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
demo1.myaccount-apps.tk
and with whatsmydns service I check that it is resolved ok:
https://www.whatsmydns.net/#CNAME/demo1.myaccount-apps.tk
- I installed nginx with "Welcome to nginx!" greeting page by
http://ec2-NN-NN-NN-NN.us-east-2.compute.amazonaws.com/
url
- Created /var/www/votes.com/index.php file
with text
File <b>/var/www/votes.com/index.php </b> index
<?php
echo ‘Hello all!’;
phpinfo();
?>
- I created file /etc/nginx/sites-available/votes.com 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/votes.com;
index index.php;
server_name demo1.myaccount-apps.tk;
# 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 127.0.0.1:9000
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):
127.0.0.1 localhost
127.0.0.2 localhost test.com
127.0.0.3 demo1.myaccount-apps.tk
- created symbol link :
sudo ln -s /etc/nginx/sites-available/votes.com /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/nginx.pid;
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 http://demo1.myaccount-apps.tk/ in browser I got 404
error
also running
curl http://demo1.myaccount-apps.tk/
in console of my server I got empty line, but I expected content of my
/var/www/votes.com/index.php file?
What is wrong and how to fix it ?
Thanks!