我的nginx有问题,我的IP地址指向我的网站,但是当我将我的域名指向该IP地址,并尝试使用我的域名(www.example.com)访问我的网站时,nginx返回404错误。这是我的代码。
user www-data;
worker_processes 4;
worker_rlimit_nofile 100000;
pid /run/nginx.pid;
events {
use epoll;
worker_connections 1024;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 200;
reset_timedout_connection on;
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;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
#gzip on;
gzip_disable "msie6";
gzip_min_length 256;
# gzip_vary on;
# gzip_proxied any;
gzip_comp_level 3;
gzip_buffers 16 32k;
# gzip_http_version 1.1;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
server{
listen 80;
server_name vidzapp.com www.vidzapp.com;
client_max_body_size 500m;
location /{
add_header 'Access-Control-Allow-Origin' "*";
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Content-Type,accept,x-wsse,origin';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
root /var/www;
index index.php;
}
location ~ \.php$ {
root /var/www/;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}
答案 0 :(得分:3)
位于@ /etc/nginx/sites-available/yourdomain.com的虚拟主机文件中
查找和添加:DOMAIN.com www.DOMAIN.com * .DOMAIN.com;到服务器名称
root /var/www/egaffar.com/datazone;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name DOMAIN.com www.DOMAIN.com *.DOMAIN.com;
location / {
# First attempt to serve request as file, then
然后输入以下命令
nginx -t&&服务nginx重启