我已经在本地机器上的 Ubuntu 12.04 上安装了 nginx 1.1.19,并保留了默认值,/etc/nginx/nginx.conf除了更改用户指令。
/etc/nginx/nginx.conf
user nginx www-data;
worker_processes 4;
pid /var/run/nginx.pid;
...
Run Code Online (Sandbox Code Playgroud)
我想在我的用户目录中使用 web 根目录创建一个简单的静态站点(假设我的用户名是“ubuntu”)。这是我的测试站点的配置。
/etc/nginx/sites-available/test-site
server {
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /home;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html; …Run Code Online (Sandbox Code Playgroud)