centOS下安装nginx

蹲街弑〆低调 提交于 2020-01-27 02:16:50

1、安装pcre-8.41

  tar -xvf pcre-8.4.1.tar.gz

  cd pcre-8.4.1

  ./configure

  make && make install

2、安装zlib-1.2.11

 

3、安装nginx

  tar -xvf nginx-1.12.2.tar.gz

  cd nginx-1.12.2

  ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11

  make && make install

 

4、nginx开机自启动

4.1 vim /etc/init.d/nginx  (红色两行一定要添加)

#! /bin/sh

 

# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/$NAME
CONFIGFILE=/usr/local/nginx/$NAME.conf
PIDFILE=/usr/local/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}

do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}

do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac

exit 0

    chkconfig --add nginx

 chkconfig nginx on

 

至此,开机启动配置完成

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!