我正在我的 Raspberry Pi 上工作,并且第一次在那里设置了 nginx 服务器。我的笔记本电脑在同一个WiFi网络中,所以我可以通过输入树莓派的IP来访问服务器。
我想将index.html 文件放在我的主文件夹中,但我很困难,想寻求您的帮助。
这是迄今为止所尝试的:
我已经通过 apt install 定期安装了 nginx,并且我可以通过 RaspberryPi IP 访问默认页面
但是当我将
index.nginx-debian.html
复制到/home/pi-simon/html
并相应地更改/etc/nginx/sites-available/default
时,它不再起作用,导致403 Forbidden
:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
# root /var/www/html;
root /home/pi-simon/html;
index index.html index.nginx-debian.html;
try_files $uri $uri/ =404;
}
根据我的
index.nginx-debian.html
位置(以及相应的 default
设置),结果会有所不同:
|
|
|
|
|
---|---|---|---|---|
结果
|
好的 | 好的 |
|
|
更改线路
try_files $uri $uri/ =404;
仅更改了403和404之间的错误输出
我仔细检查了拼写错误,并在每次更改后重新启动了 nginx
我的
nginx.conf
会错吗?
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush 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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
##
# Gzip Settings
##
gzip on;
# 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/*;
# server {
# listen 8080;
# root /data/up1;
#
# location / {
# }
# }
}
#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;
# }
#}
感谢您的支持!如果您需要更多信息,请告诉我。
我必须用 sudo chmod 750 /home/pi-simon/anavi-phat-sensors-ui
将
现在我可以通过raspberry.local访问index.nginx-debian.html。