nginx、redis在Centos7中,加入开机自启动
nginx加入开机启动
cat <<EOF >> /etc/systemd/system/nginx.service
> [Unit]
> Description=nginx – high performance web server
> After=network.target remote-fs.target nss-lookup.target
>
> [Service]
> Type=forking
> ExecStart=$NGINX_HOME/sbin/nginx -c $NGINX_HOME/conf/nginx.conf
> ExecReload=$NGINX_HOME/sbin/nginx -s reload
> ExecStop=$NGINX_HOME/sbin/nginx -s stop
>
> [Install]
> WantedBy=multi-user.target
> EOF
systemctl daemon-reload
systemctl start nginx
systemctl enable nginx
redis加入开机启动
cat << EOF >> /etc/systemd/system/redis.service
> [Unit]
> Description=Redis Server Manager
> After=syslog.target
> After=network.target
>
> [Service]
> Type=forking
> PIDFile=/home/redis4.0.9/redis_6379.pid
> ExecStart=/home/redis4.0.9/src/redis-server /home/redis4.0.9/redis.conf
> ExecStop=/home/redis4.0.9/src/redis-cli shutdown
> Restart=always
>
> [Install]
> WantedBy=multi-user.target
> EOF
systemctl daemon-reload
systemctl start redis
systemctl enable redis