基于systemd配置服务开机自启-nginx

cat > /usr/lib/systemd/system/nginx.service <<'EOF'
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload

[Install]
WantedBy=multi-user.target
EOF

systemctl enable --now nginx
上一篇:「Mac玩转仓颉内测版23」基础篇3 - 深入理解整数类型