首页 > 其他 > 详细

Nginx基本使用

时间:2016-01-28 21:11:42      阅读:238      评论:0      收藏:0      [点我收藏+]

Nginx基本使用

下载源码包http://nginx.org/

http://nginx.org/en/download.html

yum  -y install "@开发工具" pcre  pcre-devel  openssl openssl-devel

tar -zxvf nginx-XXXX.tar.gz

./configure --help

./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module

make && make install

useradd -s /sbin/nologin  -M  www

 

/usr/local/nginx/sbin/nginx 选项
-h
-s stop 停止nginx进程
-v 查看软件版本
-V 安装软件时的配置参数
-c 指定nginx进程使用那个配置文件运行
-t 检查默认的配置文件nginx.conf是否有语法错误

 

pkill   -9 nginx

kill 信号 pid号
-int
-quit
-HUP
-USR1
-USR2
-WINCH
kill   -HUP  `cat /usr/local/nginx/logs/nginx.pid`

 基本网站服务

http {

server {
listen 80;
server_name localhost;

location / {
root html;
index index.html;
}

location 路径 {
root html;
index index.html;
}
}

server {

}
}

 基于域名的虚拟主机 : 发布给公网客户端

基于端口 + 基于ip : 在私有网络发布网站后台管理页面

1.域名虚拟主机

server {
listen 80;
server_name www.xzdz.hk;
location / {
root /wwwdir;
index index.html index.htm;
}
.....
.....
}
server {
listen 80;
server_name bbs.xzdz.hk;
location / {
root /bbsdir;
index index.html;
}
}

 

2.端口虚拟主机

server {
listen 80;
location / {
root html;
index index.html;
}
}

server {
listen 8000;
location / {
root /bbsdir;
index index.html;
}

server {
listen 8090;
location / {
root /wwwdir;
index index.html;
}
}

 

3.ip虚拟主机

server {
listen 1.1.1.253:8080;
location / {
root /admindir;
index index.html;
}
}
server {
listen 1.1.1.254:80;
location / {
root /wwwdir;
index index.html;
}
}
server {
listen 1.1.1.253:80;
location / {
root /bbsdir;
index index.html;
}
}

 

 

Nginx基本使用

原文:http://www.cnblogs.com/kamil/p/5167368.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!