前提:通过源码安装apache2。
①vim /usr/lib/systemd/system/apache2.service
复制以下内容:
[Unit]
Description=apache2 - a apache web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl -k start
ExecReload=/usr/local/apache2/bin/apachectl -k restart
ExecStop=/usr/local/apache2/bin/apachectl -k stop
[Install]
WantedBy=multi-user.target
③sudo systemctl daemon-reload
④reboot