yum install gcc yum install pcre-devel yum install zlib zlib-devel yum install openssl openssl-devel 中間一路yes
wget http://nginx.org/download/nginx-1.13.7.tar.gz tar -xvf nginx-1.13.7.tar.gz -C /usr/local/nginx
cd /usr/local/nginx/ ./configure make make install
//測試配置文件 安裝路徑下的/usr/local/nginx/sbin/nginx -t 複製代碼 //啓動命令 安裝路徑下的/usr/local/nginx/sbin/nginx //中止命令 安裝路徑下的/usr/local/nginx/sbin/nginx -s stop 或者 : nginx -s quit //重啓命令 安裝路徑下的/usr/local/nginx/sbin/nginx -s reload //查看進程命令 ps -ef | grep nginx //修改配置 vi /usr/local/nginx/conf/nginx.conf
①、vim /etc/init.d/nginxnginx
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # 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: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/var/run/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 /var/run/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
②、web
##執行 chkconfig --add /etc/init.d/nginx chmod 755 /etc/init.d/nginx chkconfig --add nginx ##若是想隨系統啓動就執行 /sbin/chkconfig --level 345 nginx on
③、vim
nginx啓動、中止、無間斷服務重啓,可選 start | stop | restart | reload | status | helpbash
service nginx start service nginx stop service nginx reload