首页 > 代码库 > nginx 的使用
nginx 的使用
1、下载安装包 :wgethttp://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; #} }
nginx 的使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。