nginx_安装测试
首先安装环境:
[root@local nginx-1.9.14]# yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl--devel –y
安装之前,最好检查一下是否已经安装有nginx
$ find -name nginx
如果系统已经安装了nginx,那么就先卸载
$ yum remove nginx
$ cd /usr/local
从官网下载最新版的nginx
$ wget http://nginx.org/download/nginx-1.7.4.tar.gz
wget http://nginx.org/download/nginx-1.8.1.tar.gz
解压nginx压缩包
$ tar -zxvf nginx-1.7.4.tar.gz
会产生一个nginx-1.7.4 目录,这时进入nginx-1.7.4目录
$ cd nginx-1.7.4
接下来安装,使用--prefix参数指定nginx安装的目录,make、make install安装
$ ./configure --prefix=/usr/local/nginx $默认安装在/usr/local/nginx
$ make
$ make install
启动nginx# /usr/local/nginx/sbin/nginx
停止nginx# kill -QUIT `cat /usr/local/nginx/logs/nginx.pid`
重启nginxkill -HUP `cat /usr/local/nginx/logs/nginx.pid`
添加到自启动# echo "/usr/local/nginx/sbin/nginx">>/etc/rc.local
chmod a+x /etc/rc.local 执行这个才能设置成功
如果没有报错,顺利完成后,最好看一下nginx的安装目录
配置负载均衡
修改配置文件
[root@local html]# vi /usr/local/nginx/conf/nginx.conf
[root@local html]# cat /usr/local/nginx/conf/nginx.conf
#user nobody;
worker_processes 2;
error_log
logs/error.log;
#error_log
logs/error.log notice;
#error_log
logs/error.log info;
pid
logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr
- $remote_user [$time_local] "$request" '
# '$status
$body_bytes_sent "$http_referer" '
# '"$http_user_agent"
"$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
server 16.158.51.206:80 weight=5;
server 16.158.51.51:80 weight=5;
#server 192.168.207.131:8080
weight=2;
}
server {
listen 80;
server_name 16.158.51.2;
index index.html;
root
/data0/htdocs/www;
#charset
koi8-r;
#access_log logs/host.access.log main;
# location
/ {
# root
html;
# index
index.html index.htm;
# }
#对 "/" 启用负载均衡
location / {
proxy_pass http://mysvr; #以这种格式来使用后端的web服务器
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
#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
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;
#}
}
# another virtual host using mix of
IP-, name-, and
port-based configuration
#
#server {
# listen
8000;
# listen
somename:8080;
# server_name
somename alias another.alias;
# location / {
# root
html;
# index
index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen
443 ssl;
# server_name
localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers
HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root
html;
# index
index.html index.htm;
# }
#}
}
[root@vincentdembp html]#
启动ngnix
[root@local html]# /usr/local/nginx/sbin/nginx
重启nginx
[root@local html]#
/usr/local/nginx/sbin/nginx -s reload
$
whereis nginx
配置后台服务
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
server 16.158.51.206:8098 weight=5;
server 16.158.51.206:8097 weight=5;
#server 192.168.207.131:8080 weight=2;
}
访问测试:
@Test
public void testqueryCompAndOrders(){
String url="http://16.158.51.2/wos/comp/sendDetail";
Map map=new HashMap<String, String>();
map.put("reqId","\'C4012016042214145900001\'");
postHttpRequestParams(url, map.toString());
}
关闭防火墙
systemctl stop firewalld
设置开启不启动:systemctl disable firewalld
nginx_安装测试的更多相关文章
- Nginx_安装
1. 安装步骤 上传nginx上传nginx安装包到linux 安装gcc 1 yum -y install gcc-c++ gcc 查看是否安装gcc: 1 gcc -v 安装依赖库 1 yum - ...
- mahout 安装测试
1 下载 在http://archive.apache.org/dist/mahout下载相应版本的mahout 版本,获取官网查看http://mahout.apache.org 相关的信息
- Hbase的安装测试工作
Hbase的安装测试工作: 安装:http://www.cnblogs.com/neverwinter/archive/2013/03/28/2985798.html 测试:http://www.cn ...
- ubuntu下opencv2.4.9安装测试
ubuntu下opencv2.4.9安装测试 whowhoha@outlook.com 一.依赖包安装 1. build-essential 软件包 sudo apt-get install bui ...
- 如何在本地安装测试ECSHOP 转载
如何在本地安装测试ECSHOP 如何在本地(自己的电脑)上先安装ECShop 一.创建PHP环境 1.下载AppServ 因为ECShop在线网上商店系统是用PHP语言开发的,所以,在本地架设网店之前 ...
- 谷歌Cartographer学习(1)-快速安装测试(转载)
转载自谷歌Cartographer学习(1)-快速安装测试 代码放到个人github上,https://github.com/hitcm/ 如下,需要安装3个软件包,ceres solver.cart ...
- ubuntu-10.04的测试环境 安装测试 Coreseek开源中文检索引擎-Sphinx中文版
主要参考文档:http://www.coreseek.cn/products-install/install_on_bsd_linux/ 一. 32位版本: coreseek安装需要预装的软件: ap ...
- Centos 7.3 编译 & 安装 & 测试 facebook faiss
许多 AI 系统训练完毕,正式上线时的基本操作往往可以抽象为:在高维向量空间中,给定一个向量,寻找与之最相近的 k 个向量.当向量数目异常巨大时,如何快速地执行这一基本操作,便成为 AI 系统在工程应 ...
- Python 3.6.3 官网 下载 安装 测试 入门教程 (windows)
1. 官网下载 Python 3.6.3 访问 Python 官网 https://www.python.org/ 点击 Downloads => Python 3.6.3 下载 Python ...
随机推荐
- Maven学习总结(十一)——Maven项目对象模型pom.xml文件详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- [tsA1491][2013中国国家集训队第二次作业]家族[并查集]
m方枚举,并查集O(1)维护,傻逼题,,被自己吓死搞成神题了... #include <bits/stdc++.h> using namespace std; struct tri { i ...
- 如何删除电脑中使用过的COM端口
打开注册表编辑器:开始--运行中输入regedit就可以了 打开注册表 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\COM Name Arb ...
- [bzoj4010][HNOI2015]菜肴制作_贪心_拓扑排序
菜肴制作 bzoj-4010 HNOI-2015 题目大意:给定一张n个点m条边的有向图,求一个toposort,使得:(1)满足编号为1的点尽量在前:(2)满足(1)的情况下编号为2的点尽量在前,以 ...
- [转]十五天精通WCF——第七天 Close和Abort到底该怎么用才对得起观众
一:文起缘由 写这一篇的目的源自于最近看同事在写wcf的时候,用特别感觉繁琐而且云里雾里的嵌套try catch来防止client抛出异常,特别感觉奇怪,就比如下面的代码. public void S ...
- monitor cursor
客户提出了一个需求,他们改进了自己的程序,想证明程序现在open cursor变少了,也就是说程序运行过程中 open cursor的峰值变小了. 我写了一个脚本来进行这个监控. oracle[aaa ...
- centos7 安装vsftpd的步骤
感觉非常坑,依照网上说的没一个都測试了,可一直都报错. 不断的又一次安装不下10次,最后一次最终測试出了正确的方法. #官网配置说明## https://security.appspot.com/vs ...
- [转]趣题:一个n位数平均有多少个单调区间?---- From Matrix67
考虑这么一个 14 位数 02565413989732 ,如图所示,它的数字先逐渐变大,然后开始变小,再变大,再变小,再变大,再变小.我们就说,它一共包含了 6 个单调区间.我们的问题就是:一个 n ...
- HDU 4598
这道题其实不需要考虑具体数值,但可以肯定的是,相连边的两端点必定有一正一负,至于谁正谁负,并不重要,这是可以思考的,很明显的一个二分图性质,如果不满足此条件,是不可能满足题目第二个条件的.所以首先对题 ...
- java Regex
超全 http://www.rexegg.com/regex-lookarounds.html 这篇文章不错:http://www.cnblogs.com/lzq198754/p/5780340.ht ...