Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a command to start Apache in /etc/rc3.d that does not execute when the server reboots. The script is named S75Apache2. Someone has speculated that this is because the link has a capital "A" in the name and it might work if renamed to S75apache2.

Can anyone confirm? I've searched for documentation but cannot find an answer. I can't really test this without rebooting the server again (which I'd rather not do).

share|improve this question
    
What version of Solaris is it? If it's >= 10 you probably want an SMF service instead (I don't know if SMF was available on earlier versions). –  bahamat Jul 5 '12 at 17:24
    
We are on Solaris 10. –  BellevueBob Jul 5 '12 at 18:13
    
Then I would recommend creating an SMF service. (I assume you're not using the apache that comes with S10, since it wouldn't have legacy start up scripts). Check out manifold for easy SMF creation. –  bahamat Jul 5 '12 at 20:23

3 Answers 3

up vote 2 down vote accepted

Solaris init scripts are a pain. The capital-A doesn't matter, there's a script in /etc/rc.d that finds every file in /etc/rc3.d that starts with 'S' and runs them in numerical order.

That leaves you with Starting From The Basics:

  1. Is /etc/rc3.d/S75Apache2 set executable?

  2. Does that script have a '#!' line? Is the line correct (no non-printing bytes, etc)?

  3. If it's a bash or ksh script run it as ksh -n /etc/rc3.d/S75Apache2 start. That will tell you if it has syntax errors.

  4. If you can run that script as root, try it: /etc/rc3.d/S75Apache2 start and /etc/rc3.d/S75Apache2 stop Check carefully to see if it startshttpd and stops httpd. At the very least run the script with 'start' and 'stop' arguments yourself. Use set -x to see what the script does at run time. Check to see if what it does matches what you believe it does.

  5. Read /etc/rc3.d/S75Apache2 carefully. PATH is sparsely populated at boot, and your script may not know where some executables are at boot time, but might when run after booting. Try not to assume too much - files might not exist that you think exist, things like that.

  6. Ensure that a KnnApache2 script doesn't exist in /etc/rc3.d. I beliee that the Solaris init will run (for example) K76Apache2 stop when it transitions from run level 3 to run level 5.

  7. Ensure that the script changes user ID appropriately. This probably isn't important for Apache, given that your script probably just calls apachectl start with some prologue commands, but if you run http directly, make sure that the resulting httpd process has the correct user ID. Use sudo or something in the script to get it right.

share|improve this answer
    
The entry is a link to /etc/init.d/apache2, which is set executable (1). The first line is '#!/sbin/sh' and seems correct (2). After rebooting, we start Apache manually as root using the same link (i.e. /etc/rc3.d/S75Apache2 start) (4). All the required paths are defined in the script itself (5). Can you think of anything else to check? –  BellevueBob Jul 5 '12 at 18:13
    
Is run level 3 appropriate? I can't recall what Solaris run level 3 means. Has the kernel started up user-level networking at that point? Maybe run-leve 5 is better? I don't have a Solaris machine to check on this stuff. –  Bruce Ediger Jul 5 '12 at 18:53
    
@BruceEdiger - On Solaris run level 3 is multi-user, run level 5 is power-off, so 3 is definitely much better than 5. User-level networking is started during run level 2, so is ready by the time 3 is entered. –  alanc Sep 3 '12 at 16:54

It turns out there WAS a bug in the startup script: the LD_LIBRARY_PATH variable was not set properly. Defining that in the script will fix the problem.

For future reference, there is a log file that contains startup messages which contained the error that led to solving our problem. The file is:

/var/svc/log/milestone-multi-user-server:default.log

I found a reference to this in the /etc/rc3.d/README file. Another day, another nugget of knowledge!

share|improve this answer

Have you rolled your own Apache (i.e. compiled it from source code) or are you simply using the Apache that comes pre-installed with Solaris 10 ?

Well it doesn't really matter, if you are on Solaris 10 (or later) as you say you are you should not be using Solaris init scripts at all, you should be using SMF. (yes, technically init scripts are still supported, but as you point out they are a pain, and SMF is much better)

To start (now, and also automatically after a re-boot) the Apache 2.2 Web Server that comes pre-inststalled with Solaris 10 then simply do this:

svcadm  enable /network/http:apache2

If you have rolled your own Apache then you need to create a SMF manifest, import the manifest and off you go. Just Google for "SMF Solaris" and you will find lots of recipes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.