标签:style blog http io ar os 使用 sp java
1、下载安装包 :wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
安装 rpm -ivhnginx-release-centos-6-0.el6.ngx.noarch.rpm
or
yum install nginx
目录:/usr/sbin/nginx /etc/nginx/conf.d
启动 /usr/sbin/nginx
停止 pkill -9 nginx
加载配置: /usr/sbin/nginx -s reload
配置所在目录为“/etc/nginx/”,其中默认含有两个配置文件,一个是Nginx.conf,另一个是conf.d/default.conf。Nginx实际首先访问到Nginx.conf,而conf.d/default.conf是Nginx.conf配置文件中引用的配置文件。
配置多个域名:同一个工程下面一个主域名,一个二级域名
upstream website {
server 192.168.10.158:28080 weight=1;
}
server {
listen 80;
server_name tool.com;
location = / {
rewrite / http://tool.com/tools/jsp/index.jsp; #不加这个访问二级域名的时候跳转到一级域名主页
}
location ~ / {
proxy_pass http://website;
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_send_timeout 90;
proxy_connect_timeout 90;
proxy_read_timeout 90;
proxy_ignore_client_abort on;
}
}
server {
listen 80;
server_name testxmf.com;
#charset koi8-r;
access_log /etc/nginx/conf.d/log/host.access.log main;
location ~ / {
proxy_pass http://website;
rewrite /tools/(.+) http://tool.com/tools/$1; #一级域名首页上二级域名标签点击之后跳转到二级域名首页
proxy_set_header Host $host:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_send_timeout 90;
proxy_connect_timeout 90;
proxy_read_timeout 90;
proxy_ignore_client_abort on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
标签:style blog http io ar os 使用 sp java
原文地址:http://blog.csdn.net/w229051923/article/details/41348733