1. 程式人生 > >自啟動文件編寫。

自啟動文件編寫。

emd nginx 編寫 network targe work ins restart des

vim /lib/systemd/system/nginx.service
文件內容:

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

設置nginx開機自啟動
systemctl enable nginx.service


開啟nginx服務:
systemctl start nginx.service

vim /lib/systemd/system/mysql.service
文件內容:

[Unit]
Description=mysql
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecRestart=/usr/local/mysql/support-files/mysql.server restart
ExecReload=/usr/local/mysql/support-files/mysql.server reload
PrivateTmp=true
[Install]
WantedBy=multi-user.target

設置mysql服務開機自啟動
systemctl enable mysql.service

vim /etc/systemd/system/php-fpm.service
文件內容:

[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=True
[Install]
WantedBy=multi-user.target

設置php-fpm服務開機自啟動:
systemctl enable php-fpm.service
啟動php-fpm:

systemctl start php-fpm.service

自啟動文件編寫。