快速安装nginx
1、创建nignx用户
/usr/sbin/groupadd -f nginx
/usr/sbin/useradd -g nginx nginx
2、安装依赖
yum install gcc gcc-c++ -y #默认有的话无须安装
yum install -y pcre-devel openssl-devel #依赖(支持Nginx服务访问,以https方式访问)
3、下载软件包&编译安装
wget -q http://nginx.org/download/nginx-1.14.2.tar.gz #下载软件包
tar xf nginx-1.14..tar.gz
cd nginx-1.14.
./configure --prefix=/usr/local/nginx-1.14. --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module #根据你的需求添加编译时要带的模块
make && make install
4、软链接启动
ln -s /usr/local/nginx-1.14. /usr/local/nginx
# 这条ln命令的意义十分深远重大。这是生产环境的经验。
# 将Nginx安装路径通过软链接方式更改为/usr/local/nginx/,方便人员使用。
# 安装时指定版本号路径是为了便于查看分区当前使用的版本,也方便以后升级。
/usr/local/nginx/sbin/nginx #启动nginx 若报错说明没有创建nginx用户或者是
ln -s /usr/local/nginx-1.14./sbin/nginx /usr/local/sbin/ #做条软连接直接用nginx启动
在nginx.conf中 把user nobody的注释去掉既可
netstat -lntup|grep 查看是否有80端口
5、查看nginx的编译参数
#/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.14.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx-1.14.2 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module
6、检查语法&平滑重启
nginx -t #检查语法是否正常
nginx -s reload #平滑重启
7、精简nginx配置文件
egrep -v "#|^$" nginx.conf.default >nginx.conf #精简化/最小化默认nginx.conf配置文件信息
8、配置nginx负载均衡
# vim conf/nginx.conf
worker_processes ;
events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ;
upstream wang.com{ #服务器集群的名字
server 10.10.16.223: weight=;
server 10.10.16.252: weight=; }
server {
listen ;
server_name localhost;
location / {
proxy_pass http://wang.com; #以上面对应
proxy_redirect default;
}
error_page /50x.html;
location = /50x.html {
root html;
}
}
}
标准的配置请写在vhost下面:
[root@linux-node1 conf]# cat nginx.conf
#user www;
worker_processes auto;
worker_rlimit_nofile ; events {
worker_connections ;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout ; log_format main '$remote_addr - $host [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_addr $upstream_status $upstream_response_time $bytes_sent'; gzip on ;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_comp_level ;
gzip_types text/plain application/x-javascript text/css application/xml application/json application/javascript text/javascript image/jpeg image/gif image/png;
gzip_disable "MSIE [1-6].";
gzip_vary on;
#其他的在着重添加优化参数 include vhost/*.conf; }
处理逻辑的放在vhost下面:
[root@shenzhen conf]# pwd
/usr/local/nginx/conf
[root@shenzhen conf]# cat vhost/gunicorn.conf
server {
listen ;
server_name xx.xxx.xxx.xxx; #location / {
# root html;
# index index.html index.htm;
# } location / {
proxy_pass http://127.0.0.1:5001;
proxy_redirect default;
} error_page /50x.html;
location = /50x.html {
root html;
} access_log /data/logs/nginx/gunicorn_access.log main;
error_log /data/logs/nginx/gunicorn_error.log; }
9、终结版
一键安装openresty,配置优化等
[root@linux-node1 ~]# cd /usr/local/src
[root@linux-node1 src]# git clone https://github.com/unixwang/linux-package.git
[root@linux-node1 src]# cd linux-package/
[root@linux-node1 linux-package]# yum localinstall -y jemalloc-4.5.-.x86_64.rpm openresty-1.15.8.1-.x86_64.rpm
[root@linux-node1 vhost]# cd /usr/local/openresty/nginx/conf/vhos
[root@linux-node1 vhost]# /usr/local/openresty/nginx/sbin/nginx

快速安装nginx的更多相关文章
- CentOS 6.4 快速安装Nginx笔记
		CentOS 6.4 快速安装Nginx笔记 本系列文章由ex_net(张建波)编写,转载请注明出处. http://blog.csdn.net/ex_net/article/details/9860 ... 
- 在Mac OS X 下快速安装Nginx
		p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Helvetica; color: #8e68ff } p.p2 { margin: 0.0p ... 
- CentOS用yum快速安装nginx
		增加nginx源 vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/ ... 
- centos7下快速安装Nginx服务器
		1.添加源 默认情况Centos7中无Nginx的源,最近发现Nginx官网提供了Centos的源地址.因此可以如下执行命令添加源: sudo rpm -Uvh http://nginx.org/pa ... 
- Centos下快速安装Nginx
		1.准备工作 选首先安装这几个软件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL. Nginx是C写的,需要用GCC编译:Ngin ... 
- 快速安装Nginx及配置详解(未完待续)
		导读: Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,从2007年被德国人开发出来后可以说在市场的占有率一路飙升,因为它支持高并 ... 
- CentOS快速安装Nginx的方法,nginx如何启动重启停止
		1.防止 make: command not found,提前安装一些插件,取决于当前环境是否已安装,如果已经安装就不需要执行此命令 yum -y install gcc automake autoc ... 
- Nginx的快速安装
		1. 准备工作 1. CenterOS7.x.vmware虚拟机,安装过程参考 https://jingyan.baidu.com/article/eae0782787b4c01fec548535.h ... 
- zabbix快速安装(Ubuntu18.04, Nginx)
		ubuntu18.04快速安装zabbix4.0 https://blog.csdn.net/qq_33317586/article/details/83867756 需要安装的东西:nginx,ph ... 
随机推荐
- A1135. Is It A Red-Black Tree
			There is a kind of balanced binary search tree named red-black tree in the data structure. It has th ... 
- (转)CDN的作用与基本过程
			背景:积累大型网站开发中需要掌握的技术. CDN的作用与基本过程 https://blog.csdn.net/lihao21/article/details/52808747#comments CDN ... 
- 老项目用webpack中文乱码问题解决记录
			有个很久(有多久呢,你还记得jquery1.6的年代吗...)的项目需要新加一些功能,又想使用新的生产力工具比如说webpack,es6,vue神马的.原来的项目整体都是用GBK编码的,这特么...坑 ... 
- 【清北学堂2018-刷题冲刺】Contest 4
			Task 1:序列 [问题描述] 小H原本有一个由连续的正整数组成的序列,如{4,5,6}或{10,11,12,13,14,15,16},但是她最近睡眠不足,只能记得其中的一些数字.她想知道,她最少 ... 
- Java Web 开发必须掌握的三个技术:Token、Cookie、Session
			在Web应用中,HTTP请求是无状态的.即:用户第一次发起请求,与服务器建立连接并登录成功后,为了避免每次打开一个页面都需要登录一下,就出现了cookie,Session. Cookie Cookie ... 
- 关于web-root和web-inf的用处
			web-inf下的页面不能直接反问,必须通过servlet页面进行跳转,安全性高. web-root下的页面能直接通过地址栏来访问,安全性低. 哪些页面放在web-root下,哪些放在web-inf下 ... 
- 洛谷P1073 Tarjan + 拓扑排序 // 构造分层图
			https://www.luogu.org/problemnew/show/P1073 C国有 n n个大城市和 mm 条道路,每条道路连接这 nn个城市中的某两个城市.任意两个城市之间最多只有一条道 ... 
- jackson工具类  对象转字符串 --  字符串转对象
			这个一个json的工具类.用的是jackson,当然还有谷歌的gosn,阿里的fastjson ,但是jackson的感觉还是最成熟(网上大神说的...) 实现的功能很简单,对象转字符串 字符串转简 ... 
- layui(九)——flow组件常见用法总结
			该模块包含 信息流加载 和 图片懒加载 两大核心支持,无论是对服务端.还是前端体验,都有非常大的性能帮助.下边分别给出了这两种技术的使用方法 一.信息流加载 信息流加载的核心方法时 flow.l ... 
- android studio导出apk
			在android studio导出的apk分为4种,一种是未签名调试版apk,一种是未签名发行版apk,一种是已签名调试版apk,还有一种是已签名发行版apk.以下将介绍这4种apk如何导出. 一.调 ... 
