log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
复制代码
配置虚拟主机
创建网站目录和配置文件:
1.
创建网站目录:mkdir -p /var/www/example.com/html
chown -R nginx:nginx /var/www/example.com
chmod -R 755 /var/www/example.com
复制代码
2. 创建示例页面:echo "<html><head><title>Welcome to Example.com!</title></head><body><h1>Success! The Nginx server is working!</h1></body></html>" > /var/www/example.com/html/index.html
3. 创建虚拟主机配置文件:nano /etc/nginx/sites-available/example.com
创建网站目录:
mkdir -p /var/www/example.com/html
chown -R nginx:nginx /var/www/example.com
chmod -R 755 /var/www/example.com
复制代码
创建示例页面:
echo "<html><head><title>Welcome to Example.com!</title></head><body><h1>Success! The Nginx server is working!</h1></body></html>" > /var/www/example.com/html/index.html