服务器:阿里云轻量应用服务器
系统镜像: CentOS7.3
应用镜像: node.js 4.8.4
备注: 本篇为基本配置,更多配置请参考其他文章
-
域名解析
nginx安装位置 /usr/local/nginx
- nginx配置文件 /usr/local/nginx/conf/nginx.conf
...
http {
include mime.types;
include /usr/local/nginx/conf.d/*.conf; #加载conf.d目录下所有.conf文件
default_type application/octet-stream;
...
- 二级域名配置 /usr/local/nginx/conf.d/admin.conf
server {
listen 80; #监听端口
server_name admin.***.com; #监听地址
location / {
root /data/www/admin/; #根目录
index index.html; #设置默认页
}
}
server {
listen 80;
server_name test.***.com;
location / {
root /data/www/test/;
index index.html;
}
}
server {
listen 80;
server_name h5.***.com;
location / {
root /data/www/h5/;
index index.html;
}
}
#图片服务配置
server {
listen 80;
server_name images.***.com;
location / {
root /data/www/images/;
autoindex on; #开启目录浏览
}
}
重启nginx /usr/local/nginx/sbin/nginx -s reload