一、背景介绍
1、加入系统服务
CentOS7: systemctl restart xxxx
CentOS6: service xxxxx restart
目录文件存放在
/usr/lib/systemd/system
比如:/usr/lib/systemd/system/php-fpm.service
[root@zjt-ecs-1 system]# cat /usr/lib/systemd/system/php-fpm.service# It's not recommended to modify this file in-place, because it# will be overwritten during upgrades. If you want to customize,# the best way is to use the "systemctl edit" command.[Unit]Description=The PHP FastCGI Process ManagerAfter=network.target[Service]Type=simplePIDFile=/usr/local/php/var/run/php-fpm.pidExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.confExecReload=/bin/kill -USR2 $MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.target

[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network-online.target remote-fs.target nss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/var/run/nginx.pidExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.confExecReload=/bin/sh -c "/bin/kill -s HUP $(/bin/cat /var/run/nginx.pid)"ExecStop=/bin/sh -c "/bin/kill -s TERM $(/bin/cat /var/run/nginx.pid)"[Install]WantedBy=multi-user.target~
2、文件说明
i386是指386上编译的,386以上机器可以安装。i586以此类推。
有的rpm包是在红帽子下编译的,有的是在其他平台下编译的,含有noarch的包说明,你可以在任何平台上安装这个软件包,就是说它并不依赖于哪个特定的linux发布版。
noarch是no architecture的意思,表示这个包可以在各种不同cpu的电脑上通用
二、配置
目录
vim /usr/lib/systemd/system/nginx.service
vim /usr/lib/systemd/system/mysql.service
三、使文件生效
systemctl daemon-reload
五、操作命令
CentOS7: systemctl restart mysqlCentOS6: service mysql restart启动systemctl start nginxsystemctl start mysqlsystemctl start xxxx关闭systemctl stop nginxsystemctl stop mysqldsystemctl stop xxxx重启nginxsystemctl restart nginxsystemctl restart mysqldsystemctl restart xxxx状态systemctl status nginxsystemctl status mysqldsystemctl status xxxx

