网站弹出,青浦网站设计制作,展厅展示公司,wordpress置顶浮标这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作方法,非常不错#xff0c;具有参考借鉴价值#xff0c;需要的朋友可以参考下这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作方法,非常不错#xff0c;具有参考借鉴价值#xff0c;需要的朋友…这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作方法,非常不错具有参考借鉴价值需要的朋友可以参考下这篇文章主要介绍了centos7系统下nginx安装并配置开机自启动操作方法,非常不错具有参考借鉴价值需要的朋友可以参考下准备工作我的centos7系统是最小化安装的, 缺很多库, 首先安装必须的运行库yum install wget gcc gcc-c pcre-devel zlib-devel##创建工作目录并进入工作目录mkdir -p /z/nginx cd /z/nginx##获取nginx最新的安装包wget http://nginx.org/download/nginx-1.11.10.tar.gz##解压缩tar zxvf nginx-1.11.10.tar.gz##进入目录cd nginx-1.11.10##检测系统配置, 生成make相关文件./configure./configure执行成功会输出以下信息nginx的安装位置,以及文件路径Configuration summary using system PCRE library OpenSSL library is not used using system zlib librarynginx path prefix: /usr/local/nginxnginx binary file: /usr/local/nginx/sbin/nginxnginx modules path: /usr/local/nginx/modulesnginx configuration prefix: /usr/local/nginx/confnginx configuration file: /usr/local/nginx/conf/nginx.confnginx pid file: /usr/local/nginx/logs/nginx.pidnginx error log file: /usr/local/nginx/logs/error.lognginx http access log file: /usr/local/nginx/logs/access.lognginx http client request body temporary files: client_body_tempnginx http proxy temporary files: proxy_tempnginx http fastcgi temporary files: fastcgi_tempnginx http uwsgi temporary files: uwsgi_tempnginx http scgi temporary files: scgi_temp编译并安装make make install创建nginx启动命令脚本vi /etc/init.d/nginx插入以下内容, 注意修改PATH和NAME字段, 匹配自己的安装路径 (这段是从网上copy的)#! /bin/bash# chkconfig: - 85 15PATH/usr/local/nginxDESCnginx daemonNAMEnginxDAEMON$PATH/sbin/$NAMECONFIGFILE$PATH/conf/$NAME.confPIDFILE$PATH/logs/$NAME.pidSCRIPTNAME/etc/init.d/$NAMEset -e[ -x $DAEMON ] || exit 0do_start() {$DAEMON -c $CONFIGFILE || echo -n nginx already running}do_stop() {$DAEMON -s stop || echo -n nginx not running}do_reload() {$DAEMON -s reload || echo -n nginx cant reload}case $1 instart)echo -n Starting $DESC: $NAMEdo_startecho .;;stop)echo -n Stopping $DESC: $NAMEdo_stopecho .;;reload|graceful)echo -n Reloading $DESC configuration...do_reloadecho .;;restart)echo -n Restarting $DESC: $NAMEdo_stopdo_startecho .;;*)echo Usage: $SCRIPTNAME {start|stop|reload|restart} 2exit 3;;esacexit 0设置执行权限chmod ax /etc/init.d/nginx注册成服务chkconfig --add nginx设置开机启动chkconfig nginx on重启, 查看nginx服务是否自动启动shutdown -h 0 -rnetstat -apn|grep nginx对nginx服务执行停止/启动/重新读取配置文件操作#启动nginx服务systemctl start nginx.service#停止nginx服务systemctl stop nginx.service#重启nginx服务systemctl restart nginx.service#重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)systemctl reload nginx.service