您的位置:首页 > 运维架构 > Nginx

Nginx基本使用

2016-01-28 20:08 555 查看

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;
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: