systemd 経由での自動起動設定
/etc/systemd/system/httpd.service ファイルを作成して、以下を記述。
# cat /etc/systemd/system/httpd.service [Unit] Description=The Apache HTTP 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 graceful ExecStop=/usr/local/apache2/bin/apachectl -k stop PrivateTmp=true Restart=always OOMScoreAdjust=-1000 [Install] WantedBy=multi-user.target # systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/etc/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since 土 2017-05-27 12:10:59 JST; 5min ago Process: 3805 ExecStart=/usr/local/apache2/bin/apachectl -k start (code=exited, status=0/SUCCESS) Main PID: 3808 (httpd) CGroup: /system.slice/httpd.service ├─3808 /usr/local/apache2/bin/httpd -k start ├─3809 /usr/local/apache2/bin/httpd -k start ├─3810 /usr/local/apache2/bin/httpd -k start └─3817 /usr/local/apache2/bin/httpd -k start 5月 27 12:10:59 v*****.vir.kagoya.net systemd[1]: Starting The Apache HTTP Server... 5月 27 12:10:59 v*****.vir.kagoya.net systemd[1]: Started The Apache HTTP Server.
Loaded: loaded (/etc/systemd/system/httpd.service; disabled; vendor preset: disabled)
と、
/etc/systemd/system/httpd.service; disabled
なので、サーバー起動時に自動起動しない。
# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /etc/systemd/system/httpd.service. # systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/etc/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since 土 2017-05-27 12:10:59 JST; 6min ago Main PID: 3808 (httpd) CGroup: /system.slice/httpd.service ├─3808 /usr/local/apache2/bin/httpd -k start ├─3809 /usr/local/apache2/bin/httpd -k start ├─3810 /usr/local/apache2/bin/httpd -k start └─3817 /usr/local/apache2/bin/httpd -k start 5月 27 12:10:59 v*****.vir.kagoya.net systemd[1]: Starting The Apache HTTP Server... 5月 27 12:10:59 v*****.vir.kagoya.net systemd[1]: Started The Apache HTTP Server.
のように、
systemctl enable httpd
で、自動起動設定。
Loaded: loaded (/etc/systemd/system/httpd.service; enabled
と、enabled になった。
設定ファイルを更新したら、
systemctl daemon-reload
で、デーモン再起動して、設定ファイルを読み込ませる。