vim /usr/lib/systemd/system/nginx.service
檔案內容解釋
[unit]:服務的說明
description:描述服務
after:描述服務類別
[service]服務執行引數的設定
type=forking是後台執行的形式
execstart為服務的具體執行命令
execreload為重啟命令
execstop為停止命令
privatetmp=true表示給服務分配獨立的臨時空間
注意:啟動、重啟、停止命令全部要求使用絕對路徑
[install]服務安裝的相關設定,可設定為多使用者
以754的許可權儲存服務配置!!!
任意目錄下執行::systemctl enable nginx.service
[unit]
description=nginx - high performance web server
after=network.target remote-fs.target nss-lookup.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 stop
[install]
wantedby=multi-user.target
[unit]
description=mysql
after=network.target remote-fs.target nss-lookup.target
[service]
type=forking
execstart=/usr/local/mysql/support-files/mysql.server start
#execreload=/usr/local/mysql/support-files/mysql.server restart
#execstop=/usr/local/mysql/support-files/mysql.server stop
#privatetmp=true
[install]
wantedby=multi-user.target
[unit]
description=php
after=network.target remote-fs.target nss-lookup.target
[service]
type=forking
execstart=/usr/local/php/sbin/php-fpm
[install]
wantedby=multi-user.target
[unit]
description=redis
after=network.target remote-fs.target nss-lookup.target
[service]
type=forking
execstart=/usr/local/bin/redis-server /etc/redis.conf
execstop=kill -int `cat /tmp/redis.pid`
user=www
group=www
[install]
wantedby=multi-user.target
[unit]
description=process monitoring and control daemon
after=rc-local.service
[service]
type=forking
execstart=/usr/bin/supervisord -c /etc/supervisord.conf
sysvstartpriority=99
[install]
wantedby=multi-user.target
[unit]
description=tomcat_8200
after=syslog.target network.target remote-fs.target nss-lookup.target
[service]
type=forking
pidfile=/var/run/tomcat_8200.pid
execstart=/home/server_config/tomcat/tomcat_8200 start
execreload=/home/server_config/tomcat/tomcat_8200 restart
execstop=/home/server_config/tomcat/tomcat_8200 stop
privatetmp=true
[install]
wantedby=multi-user.target
centos 7 x編寫開機啟動服務
在系統服務目錄裡建立nginx.service檔案 vi lib systemd system nginx.service內容如下 unit description nginx after network.target service type forking execstart usr local...
centos7 X設定SVN伺服器開機啟動
systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止firewall開機啟動 firewall cmd state 檢視預設防火牆狀態 關閉後顯示notrunning,開啟後顯示runni...
centos7 x設定nginx開機自啟動
1 在 lib systemd system 下新建nginx.service檔案,內容如下 unit description nginx service after network.target service type forking execstart sbin nginx execreloa...