快速安装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 ...
随机推荐
- Django 异步化库celery和定时任务
首先要了解Django其实是个同步框架,那么多个用户发送请求时就会发生排队的情况上一个用户的请求完成后在进行下一个,这样会对影响用户体验,所有就要用到异步方法来解决. 首先我们要安装celery库 p ...
- 跟我一起用node-express搭建一个小项目[一]
我一直以为你要学nodejs你就要掌握很多东西啊!比如js最少得看10本书吧,nodejs书籍得看吧!其实呢,到最后,你会发现,因为工作,或者找工作的需要,什么不学,那些js不懂 也没有很大的关系.所 ...
- 第三十二节,使用谷歌Object Detection API进行目标检测、训练新的模型(使用VOC 2012数据集)
前面已经介绍了几种经典的目标检测算法,光学习理论不实践的效果并不大,这里我们使用谷歌的开源框架来实现目标检测.至于为什么不去自己实现呢?主要是因为自己实现比较麻烦,而且调参比较麻烦,我们直接利用别人的 ...
- io系列之常用流一
一. 读取键盘录入和数据打印 在System类中, System.out: 对应的是标准输出设备(控制台)(一个PrintStream). System.in: 对应的是标准输入设备(键盘)(一个In ...
- Day4--Python--列表增删改查,元组,range
# 一.列表# 能装东西的东西 列表中装的数据是没有限制的,大小基本上够用# 列表用[]表示# 有索引和切片 [start,end,step] ###增删改查 (重点) # 1.新增 # appent ...
- BZOJ2006 ST表 + 堆
https://www.lydsy.com/JudgeOnline/problem.php?id=2006 题意:在长度N的序列中求K段长度在L到R之间的区间,使得他们的和最大 很容易想到要求一个前缀 ...
- Win7无法安装程序提示Installer integrity check has failed的解决方法
最近小明在Win7系统中下载了一款软件,但是在下载的时候弹出了NSIS Error:Installer integrity check has failed.Common causer include ...
- Spring Boot学习记录03_一些属性配置文件
转自:http://blog.didispace.com/springbootproperties/ 多环境配置(这个地方跟maven的profile配置有点类似) 我们在开发Spring Boot应 ...
- Arduino、bootloader、BadUSB、及其相关硬件知识入门学习
内容中包含 base64string 图片造成字符过多,拒绝显示
- Hbase学习04
3.2.4 反向时间戳 反向扫描API HBASE-4811(https://issues.apache.org/jira/browse/HBASE-4811)实现了一个API来扫描一个表或范围内的一 ...