Pages

Monday, June 16, 2008

Configuring Apache 2 HTTP Server on Solaris 10

How do you configure Apache 2 HTTP Server to run automatically on Solaris 10 using rc init scripts.

Log into the Solaris box as root, or su root.
Go to the /etc/init.d directory.
Copy the apache startup script to apache2
cp apache apache2

Change the group to sys
chgrp sys apache2
Next change the flags on the file to execute
chmod u+x apache2
Open the apache2 file with your favorite editor and modify the following lines:

APACHE_HOME=/usr/apache
CONF_FILE=/etc/apache/httpd.conf
RUNDIR=/var/run/apache
PIDFILE=${RUNDIR}/httpd.pid

as follows:

APACHE_HOME=/usr/apache2
CONF_FILE=/etc/apache2/httpd.conf
RUNDIR=/var/run/apache2
PIDFILE=${RUNDIR}/httpd.pid

Check to make sure you have a valid httpd.conf file located in /etc/apache2. You can copy the httpd.conf-example file to httpd.conf. This will create a basic httpd.conf file.

Next go to the /etc/init.d directory and try executing the apache2 file. You should see something like this:

[dev1:init.d:root]#./apache2 start
httpd starting.
You can check your configuration by using a browser to check it.

Next you will want to configure it to start/stop at the various runlevels.

Go to /etc/rc0.d and add the following:
ln -s ../init.d/apache2 K17apache2
Go to /etc/rc1.d and add the following:
ln -s ../init.d/apache2 K17apache2
Go to /etc/rc3.d and add the following:
ln -s ../init.d/apache2 S51apache2
Go to /etc/rcS.d and add the following:
ln -s ../init.d/apache2 K17apache2

This will complete the configuration for your server. Next time you change run levels, or reboot, the Apache 2 HTTP Server will restart as you expect.

Addendum:

Zaphod commented on my page about using Solaris SMF. This is truly easier.

1. Check to make sure you have a valid httpd.conf file located in /etc/apache2. You can copy the httpd.conf-example file to httpd.conf. This will create a basic httpd.conf file.

2. Execute svcadm -v enable -rs apache2

3. You are now running on Apache2 on SMF.

2 comments:

  1. Surely on Solaris 10 you use the smf framework which provides a module for apache2, not init.d scripts anymore, so it's a simple matter of:

    1) Copy /etc/apache2/httpd.conf-example to httpd.conf

    2) svcadm enable apache2

    Ed

    ReplyDelete
  2. You are correct that using SMF is much easier. My example is strictly init scripts. I use SMF for other facilities like my application servers.

    I added your remarks as an addendum to the post.

    ReplyDelete