一安装make
有的centos没有make命令但后续会用到该命令 yum -y install gcc automake autoconf libtool make
二安装gc++
yum install gcc gcc-c++
三选定安装文件目录
可以选择任何目录,本文选择 cd /usr/local/src
四安装PCRE库
正常去这个网址找对应的版本ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
也可以用linux去下载wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
也可以百度云下载 pcre-8.39.tar.gz https://pan.baidu.com/s/1USeLV-5xNT46QSW216HJAg
--------------------------------------------
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make
make install
五安装zlib库
http://zlib.net/zlib-1.2.11.tar.gz 下载最新的 zlib 源码包,使用下面命令下载编译和安装zlib包
百度云的下载地址 https://pan.baidu.com/s/14qEbMpajSu1Mfs4cmS8Pxw
---------------------------------------
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
六安装openssl(某些vps默认没装ssl)
百度云下载地址 https://pan.baidu.com/s/1ZrzOF9Wxr_Ze6iKo3_onug
----------------------------------
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
七安装nginx
百度云下载地址 https://pan.baidu.com/s/1z0C070dzTMPf146jTz3Xqg
-------------------------------
cd /usr/local/src
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure # --prefix=/usr/local/src/erlang 设定安装路径
make
make install
--------------------------------
yum -y install openssl openssl-devel (如果第六步执行了这步可以忽略)
八启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
http://ipxx 正常应该出现nignx默认的欢迎页面
停止nginx ps –ef|grep nginx kill -9 xxx
重启nginx cd /usr/local/nginx/sbin ./nginx -s reload
九开机启动nginx
chmod +x /etc/rc.local
vi /etc/rc.local 然后增加如下配制
su - root -c '/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf'
十放开防火墙80端口
chkconfig iptables on设置开机启动
------------------------------------
坑error reading information on service iptables: No such file or directory
yum install iptables-services
-----------------------------------
service iptables start 启动防火墙
vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
重启防火墙 [root@h1 ~]# service iptables restart
十一启动nginx时报错
proxy_headers_hash_max_size proxy_headers_hash_bucket_size 的大小的调整
--------------------------------------------------
坑:[emerg]: could not build theproxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512or proxy_headers_hash_bucket_size: 64
-------------------------------------------------
需要在http片段中增加如下两行
http{ ...... proxy_headers_hash_max_size 51200; proxy_headers_hash_bucket_size 6400; .... } |
如下图所示
十二反向代理一个后台服务设置
location /codeGen/ { proxy_pass http://10.17.5.102:8099; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } |
十三upstream负载集群
upstream 要在http的区域里
http{
...
upstream xxxsuperaccountxxx {
server 127.0.0.1:9999 weight=1 max_fails=3 fail_timeout=30s;
server 127.0.0.1:9998 weight=1 max_fails=3 fail_timeout=30s;
}
...
server {
location /api/ {
proxy_pass http://xxxsuperaccountxxx/superaccount/api/;
}
}
十四配制阿里云的安全
打开控制台-->云服务ECS-->网络和安全-->安全组-->配制规则