http://nginx.org/download/nginx-1.17.2.tar.gzhttps://jaist.dl.sourceforge.net/project/pcre/pcre2/10.33/pcre2-10.33.tar.gzhttp://117.128.6.17/cache/www.zlib.net/zlib-1.2.11.tar.gzhttps://www.openssl.org/source/openssl-1.1.1c.tar.gzhttps://github.com/ivmai/libatomic_ops/releases/download/v7.6.10/libatomic_ops-7.6.10.tar.gzsudo yum install pcre-devel
sudo yum install gd-deval
sudo yum install geoip-devel
sudo yum install gperftools-devel
sudo yum install gcc gcc-c++
sudo yum install net-toolssudo ./configure --prefix=/usr/local/nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --with-google_perftools_module --with-pcre --with-pcre=/usr/local/src/pcre-8.43 --with-pcre-jit --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.1.1c --with-debug#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO
# Author:   licess
# website:  https://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
if [ -s /bin/ss ]; then
    StatBin=/bin/ss
else
    StatBin=/bin/netstat
fi
case "$1" in
    start)
        echo -n "Starting $NAME... "
        if $StatBin -tnpl | grep -q nginx;then
            echo "$NAME (pid `pidof $NAME`) already running."
            exit 1
        fi
        $NGINX_BIN -c $CONFIGFILE
        if [ "$?" != 0 ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
        ;;
    stop)
        echo -n "Stoping $NAME... "
        if ! $StatBin -tnpl | grep -q nginx; then
            echo "$NAME is not running."
            exit 1
        fi
        $NGINX_BIN -s stop
        if [ "$?" != 0 ] ; then
            echo " failed. Use force-quit"
            $0 force-quit
        else
            echo " done"
        fi
        ;;
    status)
        if $StatBin -tnpl | grep -q nginx; then
            PID=`pidof nginx`
            echo "$NAME (pid $PID) is running..."
        else
            echo "$NAME is stopped."
            exit 0
        fi
        ;;
    force-quit|kill)
        echo -n "Terminating $NAME... "
        if ! $StatBin -tnpl | grep -q nginx; then
            echo "$NAME is is stopped."
            exit 1
        fi
        kill `pidof $NAME`
        if [ "$?" != 0 ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
        ;;
    restart)
        $0 stop
        sleep 1
        $0 start
        ;;
    reload)
        echo -n "Reload service $NAME... "
        if $StatBin -tnpl | grep -q nginx; then
            $NGINX_BIN -s reload
            echo " done"
        else
            echo "$NAME is not running, can't reload."
            exit 1
        fi
        ;;
    configtest)
        echo -n "Test $NAME configure files... "
        $NGINX_BIN -t
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|reload|status|configtest|force-quit|kill}"
        exit 1
        ;;
esacsudo chkconfig --add nginx
sudo chkconfig --level 345 nginx on
#现在就可以使用系统管理命令来使用nginx了
sudo service nginx start|stop|reload|configtest|status
or
sudo systemctl start|stop|reload|configtest|status nginx原文:https://www.cnblogs.com/super-lulu/p/11349584.html