Solved

Starting multiple instances of apache2 on server reboot

Posted on 2011-09-25
8
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 78

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
LVL 78

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

751 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