解压pcre
tar zxf pcre-8.30.tar.gz
cd pcre-8.30/
./configure
make && make install
安装pcre库是为了兼容nginx rewrite
解压openssl
tar zxf openssl-1.0.0a.tar.gz
解压nginx
useradd nginx -M -s /sbin/nologin
添加用户(不允许登录)
tar -zxf nginx-1.1.1.tar.gz
cd nginx-1.1.1
./configure --user=nginx --prefix=/myappsoft/nginx-1.1.1 --with-openssl=../openssl-1.0.0a/ --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
make && make install
检查nginx语法
[root@localLinuxMySql nginx-1.1.1]# /myappsoft/nginx-1.1.1/sbin/nginx -t
nginx: the configuration file /myappsoft/nginx-1.1.1/conf/nginx.conf syntax is ok
nginx: configuration file /myappsoft/nginx-1.1.1/conf/nginx.conf test is successful
设置全局变量及开机启动
#增加软链接,方便升级
[root@localLinuxMySql nginx-1.1.1]# ln -s /myappsoft/nginx-1.1.1 /myappsoft/nginx
#查看软链接是否成功,如果闪动就没成功
[root@localLinuxMySql nginx-1.1.1]# ll -d /myappsoft/nginx
lrwxrwxrwx 1 root root 23 Feb 10 19:05 /myappsoft/nginx -> /myappsoft/nginx-1.1.1
#将Nginx命令加入系统全局变量,启动nginx
[root@localLinuxMySql nginx-1.1.1]# echo 'export PATH=$PATH:/myappsoft/nginx/sbin' >>/etc/profile
#使全局变量修改生效
[root@localLinuxMySql nginx-1.1.1]# source /etc/profile
#加入开机自启动
[root@localLinuxMySql nginx-1.1.1]# echo '/myappsoft/nginx/sbin/nginx' >> /etc/rc.local
配置内网服务器指向及负载均衡
#找到/myappsoft/nginx-1.1.1/conf目录下nginx.conf文件,修改以下内容
upstream webserver1 {
server 192.168.11.12:8091 weight=3;
}
upstream webserver2 {
server 192.168.0.12:8092 weight=3
}
upstream webserver3 {
server 192.168.0.12:8092 weight=3
server 192.168.0.13:8092 weight=3
}
server {
listen 8080;
server_name 192.168.1.195;
location /testapp {
proxy_pass http://webserver1;
}
location /testapp2 {
proxy_pass http://webserver2;
}
location /testapp3 {
proxy_pass http://webserver3;
}
}
参数解释:
upstream webserver { } 定义真实服务器组
server {} 定义一个服务配置
listen 8080 监听8080端口
server_name 监听的地址或IP
location / 匹配server_name后的url或IP
proxy_pass 代理参数,后接upstream定义的服务器组
启动/重启nginx
#启动nginx
[root@localLinuxMySql nginx-1.1.1]# nginx
#重启nginx
[root@localLinuxMySql nginx-1.1.1]# nginx -s reload
查看监听端口
[root@localLinuxMySql nginx-1.1.1]# netstat -plnt |grep 8080
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 32716/nginx: master
测试访问
访问:http://192.168.1.195:8080/testapp 实际是映射地址:http://192.168.11.12:8091/testapp
访问:http://192.168.1.195:8080/testapp2 实际是映射地址:http://192.168.0.12:8092/testapp2
testapp3 可以映射两台服务器地址 实现负载均衡
相关推荐
自己整理的nginx安装部署相关的一些经验,供参考
该文档讲述了nginx的具体安装步骤。根据该文档可以快速入手。nginx安装部署不再麻烦
linux中的nginx安装部署
Nginx安装部署
Nginx安装部署与配置全解析
nginx安装部署所需要的文件模板
分布式文件系统:FastDFS+Nginx安装部署所需软件;FastDFS是一个轻量级的开源分布式文件系统,主要解决了大容量的文件存储和高并发访问的问题,文件存取时实现了负载均衡。
ngin安装部署文档 详细
Nginx 安装文档,详细介绍了Nginx的安装过程和配置方法,希望大家喜欢
nginx 本着开源精神 小白一枚,大家一起努力! HTTP协议是Hyper Text Transfer Protocol(超文本传输协议)的缩写,是用于从万维网(WWW:World Wide Web )服务器传输超文本到本地浏览器的传送协议。 HTTP是一...
文档目录结构如下,实现了HTTP、HTTPS、TCP、SFTP端口...2. 安装Nginx 1 3. HTTP请求配置文件 2 4. TCP请求配置文件 3 5. HTTPS请求配置文件及引入文件 4 6. SFTP协议转发 5 7. 启动Nginx 6 8. 完整的配置文件示例 6
FastDFS
nginx安装插件包和部署包含了文档和脚本以及其中nginx的安装包是直接在linux在线下载。不是非常详细啊!
主要介绍了linux上nginx安装部署及使用过程,非常不错,具有一定的参考借鉴价值,需要的朋友参考下吧
核心技术篇:Nginx快速上手 Nginx安装部署,配合大量在线实操,搞定Nginx七大核心应用场景:反向代理、虚拟主机、域名解析、负载均衡、防盗链、url重定向、https,学完即可用。 部分文件目录: ├──01_Nginx从...
一、nginx介绍及功能讲解 二、nginx的安装 三、nginx配置相关指令 四、nginx的实例应用(项目部署)
Linux系统下安装nginx-1.14.1所需的所有包 以及rpm依赖包,安装文档 https://blog.csdn.net/weixin_41851100/article/details/89565198
1、nginx部署-Yum安装 访问nginx的官方网站:http://www.nginx.org/ Nginx版本类型 Mainline version: 主线版,即开发版 Stable version: 最新稳定版,生产环境上建议使用的版本 Legacy versions: 遗留的老版本的...