标题 说明
服务器版本 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. GPU相关资料汇总

    qemu, quick emulator systemc xilinx qemu nvdla, nvidia deep learning accelerator gpgpu-sim ffgpu ope ...

  2. Monkey 部署环境

    Monkey的介绍 它是Android系统自带一个命令行工具,可以运行在模拟器里或者真是设备中运行. Monkey是发送伪随机用户事件的工具. Monkey向系统发送伪随机的用户事件流,实现对正在开发 ...

  3. 个人项目作业——wc.exe

    一.Github项目地址 https://github.com/PIPIYing/wc 二.项目概况 项目描述 Word Count 1. 实现一个简单而完整的软件工具(源程序特征统计程序). 2. ...

  4. 个人项目作业WC

    项目github地址 https://github.com/gs735028922gs/wordc 项目相关要求 wc.exe 是一个常见的工具,它能统计文本文件的字符数.单词数和行数.这个项目要求写 ...

  5. Deep Learning with Differential Privacy

    原文链接:Deep Learning with Differential Privacy abstract:新的机器学习算法,差分隐私框架下隐私成本的改良分析,使用非凸目标训练深度神经网络. 数学中最 ...

  6. 题解-[NOI2005]瑰丽华尔兹

    题解-[NOI2005]瑰丽华尔兹 [NOI2005]瑰丽华尔兹 \(n\times m\) 的矩阵.以 \((x,y)\) 为起点.一共 \(k\) 段时间,每段时间为 \([s_i,t_i](t_ ...

  7. git clone GitLab 工程报错Repository not found

    有时使用git拉取gitlab上的项目时会出现如下的错误信息:Repository not found remote: Repository not found.fatal: repository ' ...

  8. Day2 之 元组tuple

    tuple 元组    也是有序列表 ,与list非常相似,但是tuple一旦初始化就不能修改.        name = ('a','b',1,2,3,True)            tuple ...

  9. Linux系统-scp简介&坑

    文件请见这里: https://blog.csdn.net/xingxingzhilong/article/details/82909015

  10. 基于nacos注册中心的ribbon定制规则

    前面说到基于nacos的注册发现有可以扩展实现我们自己的负载均衡算法(Nacos数据模型),来实现同集群调用,是基于spring.cloud.nacos.discovery.cluster-name参 ...