Solved

Starting multiple instances of apache2 on server reboot

Posted on 2011-09-25
8
333 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 79

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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 79

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

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

630 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