我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
我以前使用过Apache,所以我知道默认的公共web根目录通常是/var/www/。
我最近开始使用nginx,但我似乎找不到默认的公共web根。
我在哪里可以找到nginx的默认公共web根?
当前回答
查看nginx配置文件来确定。 这个命令是greps在你的机器上配置的任何东西:
cat /etc/nginx/sites-enabled/default |grep "root"
在我的机器上,它是:root /usr/share/nginx/www;
其他回答
如果您的配置不包括根/某些/绝对/路径;语句,或者它包含一个使用相对路径的语句,如root some/relative/path;,则结果路径取决于编译时选项。
如果您自己下载并编译源代码,那么可能只有一种情况可以让您对这对您意味着什么做出有根据的猜测。在这种情况下,路径将相对于使用的前缀。如果你没有更改它,它默认为/usr/local/nginx.你可以通过nginx -V找到nginx编译时使用的参数,它将——prefix作为第一个。
由于根指令默认为html,这当然会导致/usr/local/nginx/html作为你的问题的答案。
然而,如果你以任何其他方式安装nginx,所有的赌注都是失败的。您的发行版可能使用完全不同的默认路径。学习弄清楚您所选择的发行版使用哪种默认值完全是另一项任务。
Debian上Nginx的默认目录是/var/www/nginx-default。
可以查看“/etc/nginx/sites-enabled/default”文件
并找到
server {
listen 80 default;
server_name localhost;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/nginx-default;
index index.html index.htm;
}
根节点是默认位置。
你可以在nginx和apache的默认目录/var/www/中找到它,但你可以改变它。 步骤1进入“/etc/nginx/sites-available”文件夹
步骤2编辑默认文件,您可以在其中找到一个服务器块,其中将有命名为root的行,这是定义位置的内容。
nginx的默认web文件夹取决于你如何安装它,但通常它在这些位置:
/usr/local/nginx/html
/usr/nginx/html
*默认页面web分配在var/www/html *默认配置服务器etc/nginx/sites/ available /nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.php;
server_name _;
location /data/ {
autoindex on;
}
location /Maxtor {
root /media/odroid/;
autoindex on;
}
# This option is important for using PHP.
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
}
}
*默认配置服务器etc/nginx/nginx.conf
内容. .
user www-data;
worker_processes 8;
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_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/*;
}
#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;
# }
#}
IP客户端的默认访问日志var/log/nginx/…