linux下安装配置nginx并配置

Linux安装nginx,并配置ssl证书 一:先安装依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel 二:nginx的下载,解压并安装。 //进入目录 cd /usr/local //创建目录 mkdir nginx //进入目录 cd nginx //下载nginx tar包 wget http://nginx.org/download/nginx-1.13.7.tar.gz //解压nginx tar包 tar -xvf nginx-1.13. 阅读详情

一,安装nginx
有问题一步步来
nginx下载地址: http://nginx.org/en/download.html
把下载好的nginx版本放到/usr/local中
1.1 解压

[root@vw010001135067 ~]# cd /usr/local/
[root@vw010001135067 local]# tar -zvxf nginx-1.10.2.tar.gz

1.2 进入nginx文件夹,执行./configure命令

[root@vw010001135067 local]# cd nginx-1.10.2
[root@vw010001135067 nginx-1.10.2]# ./configure

报错如下:

checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found
 
./configure: error: C compiler cc is not found

出现这个错误。那么就是gcc 包没有安装。

1.2.1 安装gcc
查看gcc

[root@vw010001135067 nginx-1.10.2]# whereis gcc

安装gcc

[root@vw010001135067 nginx-1.10.2]# yum -y install gcc

安装成功后再次查看

[root@vw010001135067 nginx-1.10.2]# whereis gcc
gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

gcc安装好了。

1.2.2 继续执行./configure

[root@vw010001135067 nginx-1.10.2]# ./configure
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
......
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
 
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

1.2.3 出现如上错误。安装pcre-devel

[root@vw010001135067 nginx-1.10.2]# yum install pcre-devel

再次执行./configure

error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

如果有这个错误 那么执行

yum install zlib-devel

1.2.4 执行./configure后没有报错

[root@vw010001135067 nginx-1.10.2]# ./configure
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) 
.......
Configuration summary
 + using system PCRE library
 + OpenSSL library is not used
 + md5: using system crypto library
 + sha1: using system crypto library
 + using system zlib library
 
 nginx path prefix: "/usr/local/nginx"
 nginx binary file: "/usr/local/nginx/sbin/nginx"
 nginx modules path: "/usr/local/nginx/modules"
 nginx configuration prefix: "/usr/local/nginx/conf"
 nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
 nginx pid file: "/usr/local/nginx/logs/nginx.pid"
 nginx error log file: "/usr/local/nginx/logs/error.log"
 nginx http access log file: "/usr/local/nginx/logs/access.log"
 nginx http client request body temporary files: "client_body_temp"
 nginx http proxy temporary files: "proxy_temp"
 nginx http fastcgi temporary files: "fastcgi_temp"
 nginx http uwsgi temporary files: "uwsgi_temp"
 nginx http scgi temporary files: "scgi_temp"

1.3 如果你想使用openssl 功能,sha1 功能。 那么安装openssl ,sha1 吧

[root@vw010001135067 nginx-1.10.2]# yum install openssl openssl-devel 
[root@vw010001135067 nginx-1.10.2]# install perl-Digest-SHA1.x86_64

1.3.1 开启ssl 模块 执行./configure –with-http_ssl_module

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_ssl_module

1.3.2 启用“server+status”页,执行./configure –with-http_stub_status_module

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module

上面两个命令同时启动可以

[root@vw010001135067 nginx-1.10.2]# ./configure --with-http_stub_status_module --with-http_ssl_module

1.4 上面configure就通过了

执行make 命令,执行make install 命令

[root@vw010001135067 nginx-1.10.2]# make
[root@vw010001135067 nginx-1.10.2]# make install

至此,nginx 执行成功了

1.5 配置环境变量

在/etc/profile 中加入配置
打开配置文件

[root@vw010001135067 nginx-1.10.2]# vi /etc/profile

在配置文件中加入

#nginx configure
export NGINX_HOME=/usr/local/nginx-1.10.2
export PATH=$PATH:$NGINX_HOME/sbin

我开始像上面填写,结果nginx -v的时候查找不到。注意到上面我的nginx_home配置的地址不对。先找到nginx的安装地址

[root@vw010001135067 nginx-1.10.2]# whereis nginx
nginx: /usr/local/nginx

还真是地址写错了,把上面的改成

#nginx configure
export NGINX_HOME=/usr/local/nginx
export PATH=$PATH:$NGINX_HOME/sbin

编译完保存退出并执行

[root@vw010001135067 nginx-1.10.2]# source /etc/profile

使配置生效。

1.6 查看nginx版本

查看nginx版本

[root@vw010001135067 nginx]# nginx -v
nginx version: nginx/1.10.2

整个过程成功了!

二、修改nginx.conf
2.1 启动nginx

nginx -c conf/nginx.conf

我的nginx服务在http://10.1.135.67/,配置成功后,现在启动nginx
启动成功,在浏览器打开http://10.1.135.67/,默认端口号80.
nginx
如上图,nginx已经正常工作了。

2.2 配置tomcat服务
现在我的tomcat服务在10.1.29.15,需要通过nginx转发。那么打开nginx.conf,修改配置文件。如下,添加:

#user nobody;
worker_processes 1;
 
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
 
#pid  logs/nginx.pid;
 
 
events {
 worker_connections 1024;#最大连接数,默认为512
 accept_mutex on; #设置网路连接序列化,防止惊群现象发生,默认为on
 multi_accept on; #设置一个进程是否同时接受多个网络连接,默认为off
 #use epoll;  #事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport 
}
 
 
http {
 #文件扩展名与文件类型映射表
 include  mime.types;
 
 #默认文件类型,默认为text/plain 
 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"'; 
 
 #combined为日志格式的默认值
 access_log logs/access.log main;
 
 #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块
 sendfile  on;
 sendfile_max_chunk 100k; #每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
 
 #tcp_nopush  on;
 
 #连接超时时间,默认为75s,可以在http,server,location块。
 keepalive_timeout 65;
 
 #gzip on;
 
 upstream upload {
  server 10.1.29.15:8080;
 } 
 
 error_page 404 https://www.baidu.com; #错误页
 
 server {
  keepalive_requests 120; #单连接请求上限次数。
  listen  80; #监听端口
  server_name localhost; #监听地址 
 
  #charset koi8-r;
 
  #access_log logs/host.access.log main;
 
  location  /  {
	  proxy_connect_timeout 15s;
	  proxy_send_timeout 15s;
	  proxy_read_timeout 30m;//这个是服务器对你等待最大的时间,也就是说,当你webSocket使用nginx转发的时候,如果30分钟内没有通讯,依然是会断开的,所以,你可以按照你的需求来设定
	  proxy_set_header Host $host;
	  proxy_set_header X-Real-IP $remote_addr;
	  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	  proxy_set_header Connection "";
	  proxy_set_header Upgrade $http_upgrade;//这是webSocket的配置
      proxy_set_header Connection "upgrade";//这是webSocket的配置
	  proxy_pass http://upload; #请求转向upload 定义的服务器列表
	  client_max_body_size 1024m;
   } 
 }
}

配置好后,保存配置文件,并且重启nginx

[root@vw010001135067 nginx]# nginx -s reload

在浏览器调用upload项目是否成功
在这里插入图片描述
如图能正确访问项目,配置成功!

在Linux系统中无网络安装Nginx并配置负载均衡 通过本文的步骤,我们成功在无网络的环境中安装了Nginx,并配置了负载均衡功能。虽然无网络环境下的安装过程相对复杂,但通过手动编译和配置,我们依然能够搭建起一个高性能的Web服务器。希望本文能够帮助到需要在无网络环境下部署Nginx的开发者。如果你在安装过程中遇到任何问题,欢迎在评论区留言,我会尽力为你解答。 阅读详情

相关推荐

Linux安装Nginx,并配置多个Tomcat

下载安装Nginx,并配置多个Tomcat

qq_44875457的博客 464

安装Nginx时报错./configure: error: C compiler cc is not fund

解决安装Nginx出现的错误信息

烛照@123的博客 1012

02.Palantir Foundry平台功能和应用全景图

本文深入解析 Palantir Foundry 平台核心功能与应用全景。

694

Linux下nginx配置、使用

【代码】Linux下nginx配置、使用。

youcan_doit的博客 3947

WPS Office 2019 For Linux二次开发全流程:从源码下载到Demo运行

本文详细介绍了在Linux环境下进行WPS Office 2019 C++二次开发的全流程,涵盖从开发环境准备、源码获取、核心依赖(Qt与WPS)安装配置,到最终编译运行官方Demo的完整步骤。文章重点解析了环境搭建中的常见问题与解决方案,旨在帮助开发者快速上手WPS二次开发。

weixin_29001423的博客 390

Yolov5s可视化网络结构图

Yolov5共有四种网络结构,每种网络深度和宽度上都不相同。 (1) Yolov5s可视化网络结构图:点击查看 (2) Yolov5m可视化网络结构图:点击查看 (3) Yolov5l可视化网络结构图:点击查看 (4) Yolov5x可视化网络结构图:点击查看 ...

江南研习社 15万+

Linux中如何修改nginx的nginx.conf配置文件,并刷新生效?

Linux中如何修改nginx的nginx.conf配置文件,并刷新生效?

Ddd_victory的博客 4万+

知识图谱_知识图谱 | 知识图谱做用户画像

导读:最近一直在思考怎么用知识图谱做推荐,但是目前能知道的内容都是基于路径的推荐和基于图特征的推荐,所以能不能换一个角度,探究一下用知识图谱怎么做用户画像,因为画像也是推荐系统重要的一部分。现在的知识图谱+推荐怎么做的传统的用户画像怎么做现在的知识图谱+推荐怎么做的?基于路径:可以理解成基于图谱的多路径召回,或者多路径推荐,然后根据路径的转移概率进行排序从而达到推荐的效果,基于路径比较适合简单的推...

weixin_28801659的博客 1460

nginx报错./configure: error: C compiler cc is not found make: *** No rule to make target `build‘

checking for OS + Linux 3.10.0-1160.el7.x86_64 x86_64 checking for C compiler ... not found ./configure: error: C compiler cc is not found make: *** No rule to make target `build', needed by `default'. Stop. nginx: [emerg] unknown directive "stream"

weixin_46062349的博客 1658

从智能手机到汽车电子:聊聊IPC-9702/9704A标准如何帮我们搞定不同场景下的PCB可靠性设计

本文探讨了IPC-9702/9704A标准在智能手机和汽车电子等不同场景下的PCB可靠性设计应用。通过分析消费电子、汽车电子和工业设备中的应力特征,详细解读了IPC标准在应变识别和测试方法论中的核心价值,并提供了具体的轻量化设计策略和全生命周期验证方案,帮助工程师提升PCB的长期可靠性。

weixin_30693683的博客 280

vfsglobal预约系统登录问题全解析(by quqi99)

本文全面解析VFS Global预约系统登录常见问题,包括IP限制、验证码验证失败及账号自动删除等。提供详细的解决方案,如DNS配置、浏览器设置及邮箱选择建议,帮助用户顺利完成签证预约。特别针对中国用户遇到的IP限制问题,给出了实用技巧。

gamma的博客 1341

Linux 配置Nginx环境变量&Nginx常用命令

1、打开配置文件 vi /etc/profile 2、在PATH后面追加目录,以:隔开 /usr/local/nginx-1.20.2/sbin export JAVA_HOME=/usr/local/java/jdk1.8.0_131 export PATH=$PATH:$JAVA_HOME/bin:/usr/local/nginx-1.20.2/sbin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export J

摄氏肚的博客 5675

Centos7网络配置(设置固定ip)

刚安装完系统,有的人尤其没有勾选自动网络配置的情况下,是访问不了外网的,本机也连不通虚拟机。或者现在有的是动态ip,几次之后启动ip地址就变了,会导致其他软件或程序之前连接配置要重新更改,很麻烦,下面讲解一下如何配置网络,如何设置成固定ip。

个人笔记git:https://gitee.com/tlangp/note.git 8054

Linux下安装nginx并配置

Linux下安装nginx并配置https (本文出处: https://www.52pojie.cn/thread-881196-1-1.html ) Nginx安装 快速安装的Shell脚本 脚本2019年2月15日的稳定版本 注意自己现在所在根目录 / 新建脚本 vim nginx-install.sh #!/bin/ba...

Kinghtyj的博客 6813

lammps案例:Cu三点弯曲模拟

大家好,我是小马老师。 本文分享一个Cu弯曲的案例。 本案例参考三点弯曲实验,三点弯曲试验是将试样放在弯曲装置上,在试样上加载进行弯曲试验,直到达到规定的弯曲程度或发生断裂。 模拟原理是在z方向固定两侧端点,在x和y方向不固定,模拟左右两个支撑点,中间压块向下运动实现弯曲。 初始结构: 运行结果为: 模拟的重点是使用fix setforce命令压住左右两端,使其不能沿z轴上下移动,但是又不能在xy方向限制其移动。 压块的运动方式比较简单,给其一个下压的速度即可。 为防止压块变形,使用setforce命

lammps_jiayou的博客 2279

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

Linux安装Nginx并配置转发

通过最简单快速的方法带你了解Nginx的安装以及配置问题

qq_42227281的博客 1205

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

linux安装并配置nginx

linux安装并配置nginx

rbgg_mp的博客 4496

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

linux安装nginx并配置https——笔记

本文介绍了在Linux系统上安装和配置Nginx服务器的完整流程。首先通过yum安装必要的依赖包,然后下载并解压Nginx源码包,进行编译安装。接着详细说明了如何通过certbot工具申请SSL证书,包括安装certbot组件和生成证书的步骤。最后提供了完整的Nginx配置文件示例,包含HTTP到HTTPS的重定向设置、SSL证书路径配置和反向代理规则等关键配置项。整个过程涵盖了从基础安装到安全证书配置再到服务器优化的完整部署流程。

桂的博客 766

Linux安装nginx并配置ssl

Linux安装nginx并配置ssl

qq_40598817的博客 2989

Linux安装nginx并配置https

Linux安装nginx并配置https 第一步:安装下载nginx安装包 # 下载 /usr/local wget http://nginx.org/download/nginx-1.15.12.tar.gz # 解压 tar -zxvf nginx-1.15.12.tar.gz 第二步:编译安装并配置https # 进入nginx解压后的目录 cd /usr/local/nginx-1.15.12 # 配置ssl模块(默认配置) ./configure --with-http_ssl_module

Mr.Cheng的博客 983

Linux机器安装Nginx配置并实现双向认证

Linux机器上安装Nginx配置环境并实现双向证书认证详细实现过程总结。

杰孑的博客 2301

Linux 安装Nginx 并配置启动 (已实测)

之后就可以通过浏览器访问您的服务器的IP地址或域名来验证Nginx是否正常工作。我的启动失败了,因为我的环境有程序使用了相同的端口。

qq_41765664的博客 1万+

Linux安装Nginx并配置自启动

Linux安装Nginx并配置自启动 下载并安装nginx 去nginx官网下载地址复制稳定版本的nginx的下载链接 下载目录可以任意选择,但是最好可以统一管理一下 我是下载到 /usr/local/ 目录下的 cd /usr/local/ wget http://nginx.org/download/nginx-1.18.0.tar.gz 下载成功后安装nginx需要的依赖 yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-de

m0_38075171的博客 487

Linux安装Nginx并配置启动命令

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站 安装前准备工作 因为Nginx依赖于gcc的编译环境,所以,需要安装编译环境来使Nginx能够编译起来 yum install gcc-c++Nginx的http模块需要使用pcre来解析正则表达式,需要安装pcre yum install -y pcre pcre-devel安装依赖的解压包 yum install -y zlib zlib-develssl 功能需要 openssl 库,安装 openssl yum install -y openss

m0_60028455的博客 1166

linux下安装nginx启动,Linux下安装、配置nginx 并启动

1. 安装PCRE库(Nginx的rewrite模块和HTTP核心模块会用到PCRE正则表达式语法)使用yum来安装:yum install pcre pcre-devel2.安装OpenSSL(若服务器提供安全网页(https://)时,会用到OpenSSL库)#yum install openssl openssl-devel3.安装gcc注意:如果不安装gcc直接安装nginx的时候会报如...

weixin_39693950的博客 394

linux 安装 php7,并配置 nginx 的 php

linux 安装 php7,并配置 nginx 的 php 参阅: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-centos-7 一、 yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm 二、 yum --disablerepo="*" --enablerepo="rem

学习笔记 747
上一篇: 基于xml的AOP实现
下一篇: nginx配置同时支持https/wss协议(http/https ws/wss)都可以
柠檬酸金桔
博客等级 码龄11年 12粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值