例:apache开机启动
vi /lib/systemd/system/httpd.service
apache 开机启动配置:
[Unit]
Description=apache2.4
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache24/bin/apachectl start
ExecReload=/usr/local/apache24/bin/apachectl restart
ExecStop=/usr/local/apache24/bin/apachectl stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
配置项说明:
CentOS 7以上是用Systemd进行系统初始化的,Systemd 是 Linux 系统中最新的初始化系统(init),它主要的设计目标是克服 sysvinit 固有的缺点,提高系统的启动速度。 Systemd服务文件以.service结尾,比如现在要建立nginx为开机启动,如果用yum install命令安装的,yum命令会自动创建nginx.service文件,直接用命令systemctl enable nginx.service设置开机启动即可。
命令说明: