centos7 php、nginx、mongodb开机启动

php

vi /lib/systemd/system/php-fpm.service

[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/php-fpm -c /usr/local/php/etc/php.ini
PrivateTmp=true
[Install]
WantedBy=multi-user.target


nginx

vi /lib/systemd/system/nginx.service

[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target

mongodb
vi /lib/systemd/system/mongod.service

[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/etc/init.d/mongod --dbpath /data/mongodb --logpath /usr/local/mongodb/logs --auth --fork
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/etc/init.d/mongod --dbpath /data/mongodb  --shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target


修改对应的ExecStart   ExecReload  ExecStop的值保存就可以

加入开机启动

systemctl enable php-fpm.service

systemctl enable nginx.service

systemctl enable mongod.service

原文地址:https://www.cnblogs.com/changfengSven/p/7235315.html