1,预处理

首先处理下源

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

查看版本信息

yum info nginx

2,安装

yum install nginx

3,安装目录以及配置文件位置

安装目录  ./etc/nginx

日志目录  ./var/log/nginx
pid目录  ./var/run/nginx.pid

启动命令目录 ./usr/sbin/nginx

4,nginx启动和停止

在根目录下

启动

service nginx start

./usr/sbin/nginx

停止

service nginx stop

./usr/sbin/nginx  -s stop

查看版本号

./usr/sbin/nginx  -v

5,配置文件 nginx.conf

cd /etc/nginx

默认配置为

 1 user  nginx;
 2 worker_processes  1;
 3 
 4 error_log  /var/log/nginx/error.log warn;
 5 pid        /var/run/nginx.pid;
 6 
 7 
 8 events {
 9     worker_connections  1024;
10 }
11 
12 
13 http {
14     include       /etc/nginx/mime.types;
15     default_type  application/octet-stream;
16 
17     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
18                       '$status $body_bytes_sent "$http_referer" '
19                       '"$http_user_agent" "$http_x_forwarded_for"';
20 
21     access_log  /var/log/nginx/access.log  main;
22 
23     sendfile        on;
24     #tcp_nopush     on;
25 
26     keepalive_timeout  65;
27 
28     #gzip  on;
29 
#注意,server属性配置路径在下面 30 include /etc/nginx/conf.d/*.conf; 31 }

 配置server 属性

cd /etc/nginx/conf.d/

vi default.conf

添加

location /test/ {
            proxy_pass http://192.168.108.166:8080/;
            root   /usr/share/nginx/html;
            index  index.html index.htm;
            client_max_body_size    1000m;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 }

 

posted on 2017-03-20 11:04  wEndu  阅读(156)  评论(0编辑  收藏  举报