我是nginx场景的新手。我之前有过工作,但后来我做到了。
我试图将我的nginx网站特定文件移动到这样的目录:
var/www/site.com/html
- 而不是var/www/html
。所以我可以托管多个网站。我正在关注this教程,同时以root身份运行,所以我没有做任何权限。
我们说我的网站是example.com 这是我的/etc/nginx/nginx.conf文件:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# 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;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
##
# NGINX Bad Bot Blocker
##
#include nginx-badbot-blocker/blacklist.conf
#include nginx-badbot-blocker/blockips.conf
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
/etc/nginx/sites-available/example.com:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
#listen 80 default_server;
#listen [::]:80 default_server;
listen 80;
listen [::]:80;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/example.com/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
#server_name _;
server_name example.com www.example.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
另外,是的,我的根路径是正确的
答案 0 :(得分:0)
在 Nginx 中出现错误 --> 找不到 404 页面。 我是公司的新成员,我的任务是使用 nginx 托管网站。 所以我已经阅读了基本内容并且我已经托管了该网站,但出现错误。休耕是解决问题的方法 1 --> # nginx -t nginx:配置文件/etc/nginx/nginx.conf语法没问题 nginx:配置文件/etc/nginx/nginx.conf测试成功 2 --> systemctl 状态 nginx ● nginx.service - nginx HTTP 和反向代理服务器 已加载:已加载(/usr/lib/systemd/system/nginx.service;已启用;供应商预设:已禁用) Active:自 Thu 起处于活动状态(正在运行); 17 小时前 进程:1482 ExecReload=/usr/sbin/nginx -s reload (code=exited, status=0/SUCCESS) 进程:32393 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) 进程:32389 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) 进程:32387 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) 主 PID: 32395 (nginx) C组:/system.slice/nginx.service ├─ 1484 nginx:工作进程 ├─ 1485 nginx:工作进程 └─32395 nginx:主进程/usr/sbin/nginx 3 --> curl -vv https://testing.abc.com 获取ssl证书信息。 4 --> 对于我正在做的输出, curl -k https://testing.abc.com 出现错误 --> 404 页面未找到 你能帮助我吗。 就像我检查过闲置的东西一样, 1 --> 在 conf.d 文件夹中,我检查了网站文件夹的根路径, 2 --> 在主 nginx.conf 文件中,我提到了根路径。 3 --> 删除 nginx 包并再次安装它,但仍然出现相同的错误