下载Nginx安装包

官网下载页:http://nginx.org/en/download.html

终端输入:

# 安装依赖
yum -y install wget gcc gcc-c++ autoconf automake make zlib zlib-devel pcre-devel pcre openssl openssl-devel    
wget http://nginx.org/download/nginx-1.19.0.tar.gz

解压命令:tar -zxvf

tar -zxvf nginx-1.19.0.tar.gz 

编译安装

先进入刚才解压的目录

cd nginx-1.19.0

安装参数配置

./configure --without-http_rewrite_module --without-http_gzip_module

关于参数, --with 是指默认不会编译模块, 手动加上这个参数, 就会编译该模块

--without 是指默认会编译该模块, 如果加上该参数, 是指将该模块去除

编译和安装

make && make install

nginx默认会安装在/usr/local/nginx目录下

配置服务

vim /etc/init.d/nginx 
#添加代码
#!/bin/sh
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15

# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server

# processname: nginx
# config:     /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {

  [ -x $nginx ] || exit 5

  [ -f $NGINX_CONF_FILE ] || exit 6

  echo -n $"Starting $prog: "

  daemon $nginx -c $NGINX_CONF_FILE

  retval=$?

  echo

  [ $retval -eq 0 ] && touch $lockfile

  return $retval

}


stop() {

  echo -n $"Stopping $prog: "

  killproc $prog -QUIT

  retval=$?

  echo

  [ $retval -eq 0 ] && rm -f $lockfile

  return $retval

}



restart() {

  configtest || return $?

  stop

  start

}


reload() {

  configtest || return $?

  echo -n $"Reloading $prog: "

  killproc $nginx -HUP

  RETVAL=$?

  echo

}

force_reload() {

  restart

}


configtest() {

$nginx -t -c $NGINX_CONF_FILE

}



rh_status() {

  status $prog

}


rh_status_q() {

  rh_status >/dev/null 2>&1

}

case "$1" in

  start)

      rh_status_q && exit 0
      $1
      ;;

  stop)


      rh_status_q || exit 0
      $1
      ;;

  restart|configtest)
      $1
      ;;

  reload)
      rh_status_q || exit 7
      $1
      ;;


  force-reload)
      force_reload
      ;;
  status)
      rh_status
      ;;


  condrestart|try-restart)

      rh_status_q || exit 0
          ;;

  *)

      echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
      exit 2
esac
cd /etc/init.d
chmod 755 /etc/init.d/nginx
chkconfig --add nginx

启动

service nginx start

常用操作

全局使用nginx命令

#添加环境变量
vim /etc/profile
#加到最后
PATH=$PATH:/usr/local/nginx/sbin
export PATH
#让配置文件重新生效
source /etc/profile    

常用命令

配置检查

nginx -t

启动

service nginx start
nginx

快速关闭

nginx -s stop

从容停止服务

需要进程完成当前工作后再停止

nginx -s quit

重新载入配置文件

nginx -s reload

重启

nginx -s reopen

完成页面

Centos7编译Nginx1.19.0笔记的更多相关文章

  1. 手动编译部署LNMP环境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)

    在平时运维工作中,经常需要用到LNMP应用框架.LNMP环境是指在Linux系统下,由Nginx + MySQL + PHP组成的网站服务器架构. 可参考前面的文章: 如何在CentOS 7上搭建LA ...

  2. CentOS7 安装nginx-1.14.0

    nginx源码包:http://nginx.org/en/download.html 1.安装gcc gcc是用来编译下载下来的nginx源码 yum install gcc-c++ 2.安装pcre ...

  3. Centos7安装Nginx1.14.0

    一.官网下载 http://nginx.org/en/download.html 版本说明: Nginx官网提供了三个类型的版本 Mainline version:Mainline 是 Nginx 目 ...

  4. centos7 安装 nginx-1.18.0 并设置开机自启动

    一.到官网下载nginx Mainline  version:  nginx主力版本,为开发版 Stable version: 稳定版,在生产环境中选择此版本进行安装 Legacy versions: ...

  5. CentOS7 编译安装 Nginx (实测 笔记 Centos 7.0 + nginx 1.6.2)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  6. CentOS7编译安装Keepalived2.0.19

    实验环境:centos7 节点1:10.15.192.21 节点2:10.15.192.22 vip地址:10.15.192.23 1.下载文件 cd /usr/local/src wget http ...

  7. CentOS7 编译安装 Mongodb (实测 笔记 Centos 7.0 + Mongodb 2.6.6)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  8. CentOS7 编译安装 Mariadb (实测 笔记 Centos 7.0 + Mariadb 10.0.15)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  9. CentOS7 编译安装 Nodejs (实测 笔记 Centos 7.0 + node 0.10.33)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  10. Centos7编译安装kafka-manager-2.0.0.2

    一.kafka-manager简介 项目地址为:https://github.com/yahoo/kafka-manager 为了简化开发者和服务工程师维护Kafka集群的工作,yahoo构建了一个叫 ...

随机推荐

  1. 导出SQL SERVER 数据字典语句

    --use YourDatabase --指定要生成数据字典的数据库go SELECT 表名=case when a.colorder=1 then d.name else '' end, 表说明=c ...

  2. C#中定时任务被阻塞问题

    目录 解决一个C#中定时任务被阻塞问题 1.摘要 2.C#中定时任务的最简方法 3.定时任务阻塞现象 4.阻塞现象原因分析 5.问题解决 1.摘要 本文会介绍一个C#中最简单定时任务的使用方法,以及会 ...

  3. 智能插座的制作(esp01,继电器,arduino)

    前言: 现在小学信息技术的教材中已经出现了物联网的内容,比如泰山版小学信息技术教材第六册第二单元第一课就是用手机控制智能插座.就起了自己动手制作一个的心思,通过到网上浏览制作智能插座的文章后,有了基本 ...

  4. K8s validating data: the server could not find the requested resource ... with --validate=false

    转载: https://blog.csdn.net/yangchao1125/article/details/106193107/

  5. vue 添加代理

    1.跟目录下新建vue.config.js文件,添加内容: module.exports = {   assetsDir: 'static',   parallel: false,   publicP ...

  6. Educational Codeforces Round 143 (Rated for Div

    Educational Codeforces Round 143 (Rated for Div. 2) Problem - B Ideal Point 给定n个线段区间\([l,r]\),我们定义\( ...

  7. pip3 install

    python3 -m venv tutorial-env source tutorial-env/bin/activatepip3 install *deactivate 

  8. Outlook怎么合并相同邮件?设置Outlook邮件为对话模式

    选择View->勾选"Show as Conversations", 这样同一个标题的邮件就是叠在一块显示了. 不蟹,bro.

  9. jabc连接数据库

    Java数据库连接,(Java Database Connectivity,简称JDBC)是Java语言中用来规范客户端程序如何来访问数据库的应用程序接口,提供了诸如查询和更新数据库中数据的方法.JD ...

  10. centos7普通用户拥有root权限并登录执行脚本

    1.useradd test 2.passwd test 3.usermod -s 脚本绝对路径 test 4.vi /etc/passwd修改test用户的uid和gid为0