部署:Nginx安装和配置
一、下载
解压后目录:
二、检查配置是否正确
如下图提示标识正确
命令:nginx.exe -t
如果80端口被占用则换个其他端口即可
成功后双击nginx.exe看进程中是否执行 :如下图表示运行成功
三、浏览器验证
如显示如下页面表示访问成功
默认访问html文件加下index.html网页,如更改修改nginx.conf配置文件即可
四、目录介绍:
1、日志目录:nginx\logs
运行日志、错误日志
2、主配置文件:nginx\conf\nginx.conf (转)
Nginx.conf代码
http {
server {
#1.侦听80端口
listen 80;
location / {
# 2. 默认主页目录在nginx安装目录的html子目录。
root html;
index index.html index.htm;
# 3. 没有索引页时,罗列文件和子目录
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
# 4.指定虚拟目录
location /tshirt {
alias D:\programs\Apache2\htdocs\tshirt;
index index.html index.htm;
}
}
# 5.虚拟主机www.emb.info配置
server {
listen 80;
server_name www.emb.info;
access_log emb.info/logs/access.log;
location / {
index index.html;
root emb.info/htdocs;
}
}
}
http {
server {
#1.侦听80端口
listen 80;
location / {
# 2. 默认主页目录在nginx安装目录的html子目录。
root html;
index index.html index.htm;
# 3. 没有索引页时,罗列文件和子目录
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
}
# 4.指定虚拟目录
location /tshirt {
alias D:\programs\Apache2\htdocs\tshirt;
index index.html index.htm;
}
}
# 5.虚拟主机www.emb.info配置
server {
listen 80;
server_name www.emb.info;
access_log emb.info/logs/access.log;
location / {
index index.html;
root emb.info/htdocs;
}
}
}
3、网页根目录:nginx\html
将网页部署到当前目录下、修改配置文件