Solaris Configuration : Configuring Apache2 under SMF

Configuring Apache2 under SMFWhy we need install Apache2 under SMF manually, isn’t that configured automatically when we install the package ?
Actually, If the Apache 2 ( httpd) server is installed along with the Solaris 10 installation, the SMF entries for Apache 2 are configured by default. However, if we are installing the Solaris Apache 2 packages some time later the actual Solaris installation , then SMF for Apache 2 needs to be configured manually. This article will show you the procedure to configure apache2 under SMF , manually.

 

 

The following are the steps to set up SMF for Apache 2 on Solaris 10.

1) Crate an http-apache2 method file to /lib/svc/method

#!/sbin/sh
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident “@(#)http-apache2 1.2 04/11/11 SMI”
#

. /lib/svc/share/smf_include.sh

APACHE_HOME=/usr/apache2
CONF_FILE=/etc/apache2/httpd.conf
PIDFILE=/var/run/apache2/httpd.pid

[ ! -f ${CONF_FILE} ] && exit $SMF_EXIT_ERR_CONFIG

case “$1” in
start)
/bin/rm -f ${PIDFILE}
/bin/mkdir -p /var/run/apache2
ssl=`svcprop -p httpd/ssl svc:/network/http:apache2`
if [ “$ssl” = false ]; then
cmd=”start”
else
cmd=”startssl”
fi
;;
refresh)
cmd=”graceful”
;;
stop)
cmd=”stop”
;;
*)
echo “Usage: $0 {start|stop|refresh}”
exit 1
;;
esac

exec ${APACHE_HOME}/bin/apachectl $cmd 2>&1

2) Create a http-apache2.xml file to /var/svc/manifest/network/

 

<?xml version=”1.0″?>
<!DOCTYPE service_bundle SYSTEM “/usr/share/lib/xml/dtd/service_bundle.dtd.1”>
<!–
Copyright 2006 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.

ident “@(#)http-apache2.xml 1.3 06/03/27 SMI”
–>

<service_bundle type=’manifest’ name=’SUNWapch2r:apache’>

<service
name=’network/http’
type=’service’
version=’1′>

<!–
Because we may have multiple instances of network/http
provided by different implementations, we keep dependencies
and methods within the instance.
–>

<instance name=’apache2′ enabled=’false’>
<!–
Wait for network interfaces to be initialized.
–>
<dependency name=’network’
grouping=’require_all’
restart_on=’error’
type=’service’>
<service_fmri value=’svc:/milestone/network:default’/>
</dependency>

<!–
Wait for all local filesystems to be mounted.
–>
<dependency name=’filesystem-local’
grouping=’require_all’
restart_on=’none’
type=’service’>
<service_fmri
value=’svc:/system/filesystem/local:default’/>
</dependency>

<!–
Wait for automounting to be available, as we may be
serving data from home directories or other remote
filesystems.
–>
<dependency name=’autofs’
grouping=’optional_all’
restart_on=’error’
type=’service’>
<service_fmri
value=’svc:/system/filesystem/autofs:default’/>
</dependency>

<exec_method
type=’method’
name=’start’
exec=’/lib/svc/method/http-apache2 start’
timeout_seconds=’60’ />

<exec_method
type=’method’
name=’stop’
exec=’/lib/svc/method/http-apache2 stop’
timeout_seconds=’60’ />

<exec_method
type=’method’
name=’refresh’
exec=’/lib/svc/method/http-apache2 refresh’
timeout_seconds=’60’ />

<property_group name=’httpd’ type=’application’>
<stability value=’Evolving’ />
<propval name=’ssl’ type=’boolean’ value=’false’ />
</property_group>

<property_group name=’startd’ type=’framework’>
<!– sub-process core dumps shouldn’t restart
session –>
<propval name=’ignore_error’ type=’astring’
value=’core,signal’ />
</property_group>

</instance>

<stability value=’Evolving’ />

<template>
<common_name>
<loctext xml:lang=’C’>
Apache 2 HTTP server
</loctext>
</common_name>
<documentation>
<manpage title=’httpd’ section=’8′
manpath=’/usr/apache2/man’ />
<doc_link name=’apache.org’
uri=’http://httpd.apache.org’ />
</documentation>
</template>
</service>

</service_bundle>

 

3) Set  permissions  on both the above files, so that they can be read and executed during the system startup

# ls -l /var/svc/manifest/network/http-apache2.xml
-r–r–r– 1 root bin 2552 Feb 10 2008 http-apache2.xml
 
# ls -l /lib/svc/method/http-apache2
-r-xr-xr-x 1 root bin 698 Feb 10 2008 http-apache2

 

4) Import the http-apache2.xml file to SMF configuration

# svccfg -v import /var/svc/manifest/network/http-apache2.xml

5) Enable the Apache 2 service

# svcadm -v enable svc:/network/http:apache2

6 – Check the service running properly with the following command

# svcs http:apache2

Ramdev

Ramdev

I have started unixadminschool.com ( aka gurkulindia.com) in 2009 as my own personal reference blog, and later sometime i have realized that my leanings might be helpful for other unixadmins if I manage my knowledge-base in more user friendly format. And the result is today's' unixadminschool.com. You can connect me at - https://www.linkedin.com/in/unixadminschool/

1 Response

  1. Anil says:

    Hi Ramdev,

    Can you please explain How to set priority the SMF service?

What is in your mind, about this post ? Leave a Reply

Close
  Our next learning article is ready, subscribe it in your email

What is your Learning Goal for Next Six Months ? Talk to us