首页 > 系统相关 >Nginx安装与部署

Nginx安装与部署

时间:2023-08-06 10:04:18浏览次数:33  
标签:nginx 部署 安装 stop echo Nginx usr reload local

1、安装工具包 wget、vim和gcc

yum install -y wget  

yum install -y vim-enhanced  

yum install -y make cmake gcc gcc-c++  

2、下载nginx安装包

wget http://nginx.org/download/nginx-1.6.2.tar.gz

3、安装依赖包

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

4、解压nginx-1.6.2.tar.gz

tar -zxvf nginx-1.6.2.tar.gz

5、编译安装

./configure --prefix=/usr/local/nginx

Nginx安装与部署_nginx

Nginx安装与部署_Nginx_02

Nginx安装与部署_nginx_03

make && make install

Nginx安装与部署_Nginx_04

6、启动Nginx

./usr/local/nginx/sbin/nginx

ps -ef  |grep nginx

如果要关闭nginx,我们可以使用如下命令:

# /usr/local/nginx/sbin/nginx -s stop

如果想要重新热启动nginx,则使用如下命令:

# /usr/local/nginx/sbin/nginx -s reload

添加Nginx 到 service 启动

cd /etc/init.d/

vi  nginx

#!/bin/bash

# nginx Startup script for the Nginx HTTP Server

# it is v.0.0.2 version.

# chkconfig: 2345 30 30

# description: Nginx is a high-performance web and proxy server.

#              It has a lot of features, but it's not for everyone.

# processname: nginx

# pidfile: /usr/local/nginx/logs/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

#nginx程序路径

nginxd=/usr/local/nginx/sbin/nginx

#nginx配置文件路径

nginx_config=/usr/local/nginx/conf/nginx.conf

#nginx pid文件的路径,可以在nginx的配置文件中找到

nginx_pid=/usr/local/nginx/logs/nginx.pid

RETVAL=0

prog="nginx"

# Source function library.

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

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

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

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then

  echo "nginx already running...."

  exit 1

fi

  echo -n $"Starting $prog: "

  daemon $nginxd -c ${nginx_config}

  RETVAL=$?

  echo

  [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

  return $RETVAL

}

# Stop nginx daemons functions.

stop() {

       echo -n $"Stopping $prog: "

       killproc $nginxd

       RETVAL=$?

       echo

       [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid

}

# reload nginx service functions.

reload() {

   echo -n $"Reloading $prog: "

   #kill -HUP `cat ${nginx_pid}`

   killproc $nginxd -HUP

   RETVAL=$?

   echo

}

# See how we were called.

case "$1" in

start)

       start

       ;;

stop)

       stop

       ;;

reload)

       reload

       ;;

restart)

       stop

       start

       ;;

status)

       status $prog

       RETVAL=$?

       ;;

*)

       echo $"Usage: $prog {start|stop|restart|reload|status|help}"

       exit 1

esac

exit $RETVAL

chmod 755 /etc/init.d/nginx

chkconfig --add nginx

nginx启动、停止、无间断服务重启

 # service nginx start

 # service nginx stop

  # service nginx reload


标签:nginx,部署,安装,stop,echo,Nginx,usr,reload,local
From: https://blog.51cto.com/u_15867943/6981668

相关文章

  • Windows 在VMware Workstation 17上安装macOS Sonoma 虚拟机
    前言macOS在一些方面做得比Windows更好。但是,macOS只能安装在苹果电脑上,虽然黑苹果能满足部分人的要求,但依然有大部分机型无法安装黑苹果。而在虚拟机上,大部分用户都可以用上macOS,虽然流畅度等一般都没有白苹果、黑苹果好,但用来体验和日常使用是问题不大的。如果用来开发或编程之类......
  • nginx离线安装配置,项目部署相关配置,https ssl配置
    一、nginx安装1。通过nginx.org下载源码安装包,或直接wget下载点击链接去下载选择对应系统版本即可。我这里从稳定版【Stableversion】下载2.安装nginx依赖环境包yuminstallgcc-c++pcrepcre-develzlibzlib-developensslopenssl-devel3.上传或者下载nginx安装......
  • 阿里云部署 ChatGLM2-6B 与 langchain+chatGLM
    1.ChatGLM2-6B部署更新系统apt-getupdate安装gitapt-getinstallgit-lfsgitinitgitlfsinstall克隆ChatGLM2-6B源码gitclonehttps://github.com/THUDM/ChatGLM2-6B.git克隆chatglm2-6b模型#进入目录cdChatGLM2-6B#创建目录mkdirmodel#进入......
  • CentOS安装podman-compose
    1.安装python3的依赖yum-yinstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgdbm-develdb4-devellibpcap-develxz-devellibffi-devel如果当前登录的是普通用户,需要在命令前加sudo,否则不用,下文同理。2.下载python3的......
  • Hadoop完全分布式集群安装
    Hadoop完全分布式集群安装使用版本:hadoop-3.2.0安装VMware看一下这张图,图里面表示是三个节点,左边这一个是主节点,右边的两个是从节点,hadoop集群是支持主从架构的。不同节点上面启动的进程默认是不一样的。下面我们就根据图中的规划实现一个一主两从的hadoop集群安装hado......
  • NGINX版本升级
    检查当前版本信息/usr/local/nginx/sbin/nginx-V下载新版本nginx可在http://nginx.org/download网站查询版本信息,下载当前最新版nginx-1.25.1wgethttp://nginx.org/download/nginx-1.25.1.tar.gz解压cpnginx-1.25.1.tar.gz/opttarzxvfnginx-1.25.1.tar.gz&&cdnginx-1.25......
  • 备控N5105 G30B安装群晖
    1.安装前准备1.1.硬件准备U盘2.5寸,7-9mm,机械SATA硬盘(倍控送的SATA线很长,极难安装......
  • INS-10013:安装程序检测到此系统的中央资源清册中未注册当前home
    错误信息【汉】INS-10013:安装程序检测到此系统的中央资源清册中未注册当前home【英】INS-10013:Theinstallerhasdetectedthatcurrenthomeisnotregisteredinthecentralinventoryonthissystem.例CentOS7操作系统中,在安装Oracle数据库软件时报错。版本Oracle【11.2.0.......
  • centos7.9 部署mongodb-4.4.18 分片集群
    准备基本环境名称ip地址cpu内存es监听端口redis-65110.0.2.18c64G9200redis-65210.0.2.28c64G9200redis-65310.0.2.38c64G9200......
  • nginx 基本概念
    Nginx基本概念一、什么是Nginx是一款高性能的HTTP服务器和反向代理服务器,同时支持IMAP/POP3/SMTP代理服务。由俄罗斯的程序员伊戈尔·西索夫开发,官网测试能够支撑5万多并发链接,并且CPU、内存等资源消耗却非常低,运行非常稳定。由C语言编写。二、Nginx特点......