Question & Answer
Question
How to configure IBM HTTP Server to autostart in Linux ?
Answer
On Demand Consulting
Author: Patrick Nogay
If you are on a modern version of Linux that supports systemd then this article has examples for configuring a service to autostart IBM HTTP Server when Linux is rebooted.
1) First create a script that will start or stop IBM HTTP Server (IHS) using the apachectl command.
In this example IHS is installed in /opt/app/IBM/IHS855, and the startscript ihs.sh will be placed in directory /opt/app/IBM/startscripts
Here is the content of /opt/app/IBM/startscripts/ihs.sh:
#!/bin/sh
#
# Starts the IBM HTTP Server
# This should be copied into /opt/app/IBM/startscripts/ibmIHS.sh
#
# description: Runs IHS Server
# Source function library.
#======================================================================
#======================================================================
start() {
echo "$0: starting IBM HTTP Server"
/opt/app/IBM/IHS855/bin/apachectl -k start -f /opt/app/IBM/IHS855/conf/httpd.conf
echo "IHS Startup completed"
}
#==============================================================================
stop() {
echo "$0: stopping IBM HTTP Server"
/opt/app/IBM/IHS855/bin/apachectl -k stop -f /opt/app/IBM/IHS855/conf/httpd.conf
echo "IHS Shutdown completed"
}
case $1 in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
*)
echo "usage: $0 {start|stop|restart}"
;;
esac
##### Do not include this in the ihs.sh file #####
2) Create the ibmIHS.service file and copy it into /usr/lib/systemd/system
The ibmIHS.service will be registered with Linux systemd to execute during shutdown and startup.
The following contents should be placed in /usr/lib/systemd/system/ibmIHS.service:
####################################################################
#Create Startup Service using systemd
#Put this file in /usr/lib/systemd/system/ibmIHS.service
####################################################################
[Unit]
Description=IBM HTTP Server
[Service]
Type=oneshot
ExecStart=/opt/app/IBM/startscripts/ihs.sh start
ExecStop=/opt/app/IBM/startscripts/ihs.sh stop
User=root
RemainAfterExit=yes
[Install]
WantedBy=default.target
#### Do NOT include this line in the ibmIHS.service file ####
3) Register the ibmIHS.service with Linux
Run the following commands to register the ibmIHS.service with Linux:
cd /usr/lib/systemd/system
systemctl enable ibmIHS
?
Was this topic helpful?
Document Information
Modified date:
16 March 2019
UID
ibm10771827