侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

nginx编译安装加入service

2023-11-13 星期一 / 0 评论 / 0 点赞 / 43 阅读 / 2009 字

centos6.x版本vi/etc/init.d/nginx#!/bin/bash# chkconfig: - 30 21# description: http service.# Source Fu

centos6.x版本

vi/etc/init.d/nginx

#!/bin/bash# chkconfig: - 30 21# description: http service.# Source Function Library. /etc/init.d/functions# Nginx SettingsNGINX_SBIN="/usr/local/nginx/sbin/nginx"NGINX_CONF="/usr/local/nginx/conf/nginx.conf"NGINX_PID="/usr/local/nginx/logs/nginx.pid"RETVAL=0prog="Nginx"start() {        echo -n $"Starting $prog: "        mkdir -p /dev/shm/nginx_temp        daemon $NGINX_SBIN -c $NGINX_CONF        RETVAL=$?        echo        return $RETVAL}stop() {        echo -n $"Stopping $prog: "        killproc -p $NGINX_PID $NGINX_SBIN -TERM        rm -rf /dev/shm/nginx_temp        RETVAL=$?        echo        return $RETVAL}reload(){        echo -n $"Reloading $prog: "        killproc -p $NGINX_PID $NGINX_SBIN -HUP        RETVAL=$?        echo        return $RETVAL}restart(){        stop        start}configtest(){    $NGINX_SBIN -c $NGINX_CONF -t    return 0}case "$1" in  start)        start        ;;  stop)        stop        ;;  reload)        reload        ;;  restart)        restart        ;;  configtest)        configtest        ;;  *)        echo $"Usage: $0 {start|stop|reload|restart|configtest}"        RETVAL=1esacexit $RETVAL

chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on


centos7.x版本

vim /usr/lib/systemd/system/nginx.service

[Unit]Description=nginx - high performance web server Documentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target[Service]Type=forkingPIDFile=/var/run/nginx.pidExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.target

systemctl enable nginx.service
systemctl start nginx.service

广告 广告

评论区