标题 说明
服务器版本 Centos7 x64
nginx版本 1.19.6
作者 walton

一、准备

  1. 创建安装包目录并进入
mkdir /usr/dev/nginx

cd /usr/dev/nginx
  1. 下载安装包
wget http://nginx.org/download/nginx-1.19.6.tar.gz

或者

在 http://nginx.org/download/ 直接下载对应版本安装包上传到服务器文件夹内

Q: 如何获取下载版本?

A: 在此网站中(http://nginx.org/download/)获取版本,然后修改wget命令后的版本号

  1. 解压安装包并进入
tar -zxvf nginx-1.19.6.tar.gz

cd /nginx-1.19.6

二、安装

  1. 设置安装路径(默认路径:/usr/local/nginx)
[root@fanzyx nginx-1.19.6]#  ./configure --prefix=/usr/local/nginx

出现如下错误

./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.

需要安装openssl,执行以下命令

[root@fanzyx nginx-1.19.6]# yum -y install openssl openssl-devel

再次执行命令
[root@fanzyx nginx-1.19.6]# ./configure --prefix=/usr/local/nginx

  1. 编译nginx
当前目录下执行make命令,该命令是将源文件编译为可执行文件

[root@fanzyx nginx-1.19.6]# make

编译成功,如图所示、

  1. 安装文件

将编译后的文件复制到设置的安装目录

[root@fanzyx nginx-1.19.6]# make install

三、相关命令

  1. 启动

为nginx指定配置文件路径并启动

[root@fanzyx nginx-1.19.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

  1. 停止
方法一:
[root@fanzyx nginx-1.19.6]# /usr/local/nginx/sbin/nginx -s stop
方法二:
查询nginx进程
ps -ef | grep nginx
[root@fanzyx nginx-1.19.6]# ps -ef | grep nginx
root 15038 1 0 11:44 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 15039 15038 0 11:44 ? 00:00:00 nginx: worker process
root 15084 9881 0 11:45 pts/0 00:00:00 grep --color=auto nginx 在进程列表中带master的进程就是主进程 kill -QUIT 主进程号
eg: kill -QUIT 15038 再次执行查询命令发现主进程已消失 [root@fanzyx nginx-1.19.6]# kill -QUIT 15038
[root@fanzyx nginx-1.19.6]# ps -ef | grep nginx
root 15271 9881 0 11:50 pts/0 00:00:00 grep --color=auto nginx
[root@fanzyx nginx-1.19.6]#

  1. 重启
安装路径 -s reload

/usr/local/nginx/sbin/nginx -s reload
  1. 查看配置是否正确
安装路径 -t

/usr/local/nginx/sbin/nginx -t

如下所示配置成功
[root@fanzyx nginx-1.19.6]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@fanzyx nginx-1.19.6]#

阿里云centos7[linux]安装nginx的更多相关文章

  1. 阿里云centos7成功安装和启动nginx,但是外网访问不了的解决方案

    问题环境: 阿里云centos7.4.1708 问题描述:成功配置,启动成功,外网访问不了 解决方案: 经过查阅文档,去阿里云后台查看,原来是新购的服务器都加入和实例安全组. (OMG)立即去配置.加 ...

  2. 阿里云centos7搭建php+nginx环境

    阿里云Centos搭建lnmp(php7.1+nginx+mysql5.7) https://jingyan.baidu.com/article/215817f7a10bfb1eda14238b.ht ...

  3. 阿里云CentOs7上安装Tomcat

    一.下载安装tomcat8 cd /usr/ #创建tomcat目录 mkdir tomcat #从网上download 压缩包 wget tomcat8 url #解压 tar -zxvf apac ...

  4. 阿里云CentOS-7.2安装mysql

    我下载的阿里云的服务器系统centos7.2是纯内核版本,并没有其他的工具,所以这个系统是非常干净的.所以我就需要给系统安装一一些工具,来方便系统的管理与操作,我们上面讲到了关于服务器的yum的配置在 ...

  5. 阿里云 centos7 django + uWSGI+Nginx + python3 部署攻略

    centos7+nginx+python3+django+uwsgi配置Django 项目部署   1.租的服务器(选择centos)的话,需要在阿里云后台控制台开放几个端口,克隆一下已开放的端口,t ...

  6. 阿里云CentOS7.x安装nodejs及pm2

    对之前文章的修订 您将了解 CentOS下如何安装nodejs CentOS下如何安装NVM CentOS下如何安装git CentOS下如何安装pm2 适用对象 本文档介绍如何在阿里云CentOS系 ...

  7. 阿里云服务器新手安装nginx

    1.域名购买之后 备案. 2.购买服务器. 3.这两个条件具备之后进行下一步. 本人使用Mac ,实践流程按照Mac本的流程操作. 作为初学者,简配的服务器, 实例类型: I/O优化,操作系统: Ce ...

  8. 关于 阿里云 的linux 安装 jdk和tomcat 中的问题(解压版的jdk和tomcat)

    一安装jdk 1:首先要申请一个服务器 2:其次官网下载jdk(按你的linux版本下载(我的目前是64)) 3:就是上传jdk 4:在 usr 文件夹下创建 java 文件夹 5:把jdk上传到ja ...

  9. 阿里云CentOs7上安装GitLab

    一.安装 基本上可以根据官网的教程来安装:https://www.gitlab.com.cn/installation/#centos-7 只不过我们暂时没有邮件服务器,所以postfix没有安装. ...

随机推荐

  1. 开始是为了结束,结束是新的开始——NOI 2020 游记

    Day 0 报道日 晚上的时候我们的教练给我们做考前动员.给我们讲:NOI的五个小时需要认真的规划,不能被T1打乱节奏.他让我们思考明天的策略,把可能出问题的地方都想清楚. 结果后来,宿管给我测体温, ...

  2. linux关闭在线登录用户

    在使用电脑的时候,发现自己的电脑上有其他的用户登陆.如果其他用户用的是自己的名字,那么就能通过who去查询出来,但是如果登陆的都是root用户,那么肯定不知道是谁,所以需要我们清除他们:另外呢,如果登 ...

  3. 这个大学在Github开源了计算机课程,看完在家上个 985

    微信搜「后端技术学堂」有干货,本文已收录于Github:https://github.com/imcoderlemon/CodeClass 内含原创干货文章,千本计算机电子书,3本LeetCode题解 ...

  4. (byte & 0xff)操作

    先看一段代码: @Test public void test(){ byte a = -5; byte b = 12; System.out.println(a); System.out.printl ...

  5. js上 十五、数组-1

    十五.数组-1 #1.什么是数组 组:由多个成员构成的一个集体. 数组:数组是值的有序集合 值就是前面所讲过的这些数据(各种数据类型的都可以) 是数组中,每一个值(如100,'js',true)都称之 ...

  6. 栈的应用:表达式括号匹配检测(C)

    问题说明: 假设数学表达式中允许包含两种括号:圆括号"()"和方括号"[]",嵌套顺序任意. 正确的嵌套模式:( [ ] ( ) ).[ ( [ ] [ ] ) ...

  7. MybatisPlus_01

    目录 1.1 简介 1.1.1 特性 1.1.2 框架结构 2.1 快速开始 2.1.1 2.1.2 yaml文件配置 2.1.3 编码 2.1.4 测试 3.1 思考 1.1 简介 MyBatis- ...

  8. 工具-Redis-与Python一起使用(99.6.3)

    @ 目录 1.安装 2.使用 以下为对应的方法 3.使用string为例子 关于作者 1.安装 pip install redis 2.使用 pip install redis from redis ...

  9. 容器编排系统k8s之Service资源

    前文我们了解了k8s上的DemonSet.Job和CronJob控制器的相关话题,回顾请参考:https://www.cnblogs.com/qiuhom-1874/p/14157306.html:今 ...

  10. k8s之深入解剖Pod(一)

    上文说了一下k8s的简单使用,接下来就让我们来具体深入了解一下Pod.为了避免篇幅太长,所以会分成几篇. 目录: Pod定义详解 静态Pod Pod容器共享Volume 一.Pod定义详解 先看一个简 ...