# 一、nginx ```bash vi /lib/systemd/system/nginx.service ``` ```toml [Unit] Description=The NGINX HTTP and reverse proxy server #After=syslog.target network.target remote-fs.target nss-lookup.target After=syslog.target network.target [Service] Type=forking PIDFile=/data/nginx/logs/nginx.pid ExecStartPre=/data/nginx/sbin/nginx -t ExecStart=/data/nginx/sbin/nginx ExecReload=/data/nginx/sbin/nginx -s reload ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target ``` # 二、dockerd # 三、mysqld # 四、haproxy ```bash cd /data/install/haproxy-1.8.13/contrib/systemd/ make PREFIX=/usr/local/haproxy sudo cp haproxy.service /lib/systemd/system/haproxy.service ``` # 五、keepalived # 六、命令 ```bash systemctl daemon-reload systemctl enable nginx.service systemctl start nginx.service systemctl stop nginx.service systemctl reload nginx.service systemctl restart nginx.service systemctl status nginx.service ``` # 七、参考 * [systemd (简体中文)](https://wiki.archlinux.org/index.php/systemd_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)) * [NGINX systemd service file](https://www.nginx.com/resources/wiki/start/topics/examples/systemd/) * [Control Docker with systemd](https://docs.docker.com/config/daemon/systemd/) [systemd](https://github.com/moby/moby/tree/master/contrib/init/systemd) * [Managing MySQL Server with systemd](https://dev.mysql.com/doc/refman/8.0/en/using-systemd.html) * [编译MySQL 5.7加入systemd支持](https://blog.frognew.com/2017/03/compile-mysql-5.7-with-systemd-support.html) * [MariaDB](https://mariadb.com/kb/en/library/systemd/) * [PostgreSQL 11](https://www.postgresql.org/docs/current/server-start.html) * [在systemd单元中使用环境变量](https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html)