zoukankan      html  css  js  c++  java
  • Linux-编译安装Nginx

    编译安装Nginx

    环境:

    Nginx : Nginx-1.12.0               Server : Centos7.6

    安装:

    [root@localhost ~]# yum -y install pcre-devel zlib-devel gcc*

    [root@localhost ~]# useradd -M -s /sbin/nologin nginx

    [root@localhost ~]# tar zxvf nginx-1.12.0.tar.gz

    [root@localhost ~]# cd nginx-1.12.0/

    [root@localhost nginx-1.12.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module

    [root@localhost nginx-1.12.0]# make && make install

    [root@localhost nginx-1.12.0]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

    创建服务启动脚本:

    #!/bin/bash

    # chkconfig: - 99 20

    # description: Nginx Server Control Script

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

    PIDF="/usr/local/nginx/logs/nginx.pid"

    case "$1" in

    start)

       $PROG

      ;;

    stop)

      kill -s QUIT $(cat $PIDF)

      ;;

    restart)

      $0 stop

      $0 start

      ;;

    reload)

      kill -s HUP $(cat $PIDF)

      ;;

    status)

      [ -f $PID ] &> /dev/null

           if [ $? -eq 0 ]

              then

              netstat  -anpt | grep nginx

           else

              echo "Nginx is not running."

            fi  

      ;;

    *)

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

    esac

    exit 0

     

    [root@localhost ~]# chmod +x /etc/init.d/nginx

    [root@localhost ~]# chkconfig --add nginx

    [root@localhost ~]# systemctl status nginx

    [root@localhost ~]# systemctl restart nginx

  • 相关阅读:
    杭电 搜索 1253 胜利大逃亡
    杭电 搜索 1258 Sum It Up
    杭电搜索 2612 Find a way
    杭电 搜索 水题1072 Nightmare
    杭电1175简单搜索 连连看
    杭电 1372 Knight Moves
    杭电 oj Rescue 1242
    杭电 1241 Oil Deposits
    杭电 2100 Children’s Queue
    杭电 1103 Flo's Restaurant
  • 原文地址:https://www.cnblogs.com/Vampire-MIn/p/13073429.html
Copyright © 2011-2022 走看看