Background: Recently I wanted to write something and put it online. I bought a domain name and a vps, and also set up an ngxin server on the vps. I wanted to start with the simplest static page, so I wrote it myself. A static page index.html is uploaded to the /home/peng/var/www directory through ftp, and then the server node is configured under the http node of the nginx.conf file:
server {
listen 80 ;
server_name **.**.**.**;
index index.html;
root /home/peng/var/www;
}
Finally restarted the nginx service,
But the problem is
Every time I access the domain name address, the nginx welcome page is always returned, as if the configuration has not taken effect at all
The domain name address is: ethanvae.com
This is my first time using nginx, so the question may be very simple. I want to understand it.
1) My idea: return static files directly through nginx. Is this idea feasible? Is it wrong?
2) Are there any good tutorials that start from practice and go into depth about what nginx is, its features, usage scenarios, etc.
Although the question is very simple, I have been confused for an nginx novice for a day
Thank you again for those who can answer
The entire nginx.conf configuration file is as follows
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80 ;
server_name ethanvae.com;
location / {
index index.html;
root /home/peng/var/www;
}
}
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
}
In your
server
module add:nginx supports static HTML web pages by default.
Bind the IP with the ethanvae.com domain name provider (resolution may take time, ping at any time to see if it is successful)
server_name then write ethanvae.com www.ethanvae.com two domain names
Explanation: Restart after changing the nginx configuration file nginx only takes effect
You may encounter other problems, explain them in the comments, and I will help you solve them when I am online.
The original poster’s problem is the lack of location configuration.
The following is a simple configuration of one of my sites. I’ll send it to you for reference. It may be useful.
server{
}
server{
}
Visually, the file has not been corrected.
Run
sudo nginx -t
看看打印出来的配置文件是哪个,修改那个,然后再sudo nginx -s reload
and try it.Also, take a look at nginx’s access_log and error_log. Check to see what errors are reported and whether there have been any requests.