Solved

Starting multiple instances of apache2 on server reboot

Posted on 2011-09-25
8
319 Views
Last Modified: 2012-05-12
Hi,
I have multiple instances of apache2 reunning on a solaris 10 box. I want all the apache instances to automatically start once the physical server is rebooted.
Appreciete if someone can guide me how to modify the rc3.d script for doing this.

Thanks,
Mohit
0
Comment
Question by:Mohit_t
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36596943
Is there a specific reason you are running multiple Apache instances on the same box?
0
 
LVL 76

Expert Comment

by:arnold
ID: 36596966
You can configure a single controlled instance to listen on multiple IPs, and ports.
Please provide additional details on your question.
0
 

Author Comment

by:Mohit_t
ID: 36597051
Hi,
Yes we are using multiple websites as one site caters to normail users and the other website is for text base browsers. We use the same code base but filter out JS and other fancy stuff for text base browsers. I think running multiple websites on one box vs running them on different boxes is not negotiable.

We are running virtual solaris 10 containers and have one VIP assigned to each virtual box, so we are running multiple apache instances on one box on different ports. Also there are FW and Load Balancers in between.

arnold please let me know what further details you need.
We are running multiple apache instances and want to modify rc3.d script so that all the apache instances come up on server reboot. Right now we have to manually start all the apache instances.
OS: Solaris 10
Apache: apache2.2

Appreciate help of all the gurus and geniuses.

Thanks
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36597189
You can run both websites from the same Apache instance using virtual hosts.  It's a very common practice with lots of documentation and examples.  I don't even remember the last time I setup Apache and not used virtual hosts.

Check out http://httpd.apache.org/docs/2.0/vhosts/
You will want to setup name-based vhosts -  http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Examples -- http://httpd.apache.org/docs/2.0/vhosts/examples.html

You should be able to get all you need accomplished by reading through those links, it even has examples of exactly what you are trying to do with the multiple instances.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 76

Expert Comment

by:arnold
ID: 36597373
If you don't want to consolidate the multiple configuration into a single instance that will include the various others, you should copy the apache2 start script and adjust each start script to match the settings you want.
Another option depending on your scripting skills, you could modify the apache2 to have the capacity to start all the instances you want.

You are using the svcadm, rather than the legacy scripting.
You can use svccfg to export the existing apache service and then import a modified one as a new service per instance.

http://www.cims.nyu.edu/cgi-systems/man.cgi?section=1M&topic=svccfg



Do you have a reverse proxy that handles the differentiation between the regular access and the text only?

0
 
LVL 19

Accepted Solution

by:
xterm earned 250 total points
ID: 36599648
- Copy /etc/init.d/apache to /etc/init.d/apache2
- Edit /etc/init.d/apache2, comment out the line near the end that contains apachectl, and replace it with the command that you use to start your second instance of apache
- After you've tested the script to make sure it starts your other apache, then copy it to /etc/rc3.d/S50apache2

Keep in mind that this modified script will only work to START your 2nd instance of apache - it will not work to STOP apache.
0
 
LVL 4

Assisted Solution

by:Anacreo
Anacreo earned 250 total points
ID: 36712239
You should find out if you have your first httpd instance running via SMF:


159 / >svcs http
STATE          STIME    FMRI
disabled       Sep_21   svc:/network/http:apache2

If so then you'll want to clone the service and start a new one:
There is a good write up at (http://www.petertribble.co.uk/Solaris/smf.html)

But you'd basically do:
cp /lib/svc/method/httpd-apache2 /lib/svc/method/site-httpd-apache2

cp /var/svc/manifest/network/httpd-apache2.xml /var/svc/manifest/site/httpd-apche2.xml

Edit both files as appropriate, the first to start the apache instance you want, the second to point to the first file with any applicable parameters, also make sure to change the service name.

Now import them:
/usr/sbin/svccfg -v import /var/svc/manifest/site/httpd-apche2.xml

From the link here is good advice on troubleshooting it:

# svcs -vx smtpd (replace this with httpd, here and below)
svc:/network/smtp:postfix (postfix SMTP mail transfer agent)
 State: online since Wed Feb 09 11:05:04 2005
   See: man -M /etc/postfix/man -s 1 postfix
   See: /var/svc/log/network-smtp:postfix.log
Impact: None.
I found that the easiest way to correct a fault in the manifest was to edit the file, then delete the entry and re-import the file. :-

svcadm -v disable svc:/network/smtp:postfix
svccfg -v delete svc:/network/smtp:postfix
svccfg -v import /var/svc/manifest/site/postfix.xml
0
 
LVL 4

Expert Comment

by:Anacreo
ID: 36712262
In my previous post...

If the command
# svcs http

If it returns disabled, you'll want to follow previous poster about copying the legacy /etc/init.d script.

If it returns enabled, you may want to consider my advice.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now