How to start the right instance of Apache on RedHat server

Hi,

I have 2 apache instance on my machine (RedHat), and i need to start the "apache2" after any reboot but could not find the way ( searching into "httpd.conf" ), so i'am starting "apache2" manually.

After a reboot, none of them starts and when i when doing : httpd -k start, i got "apache" and not "apache2", so i stop "apache" with " http -k stop" than launch "apache2" with : /etc/init.d/httpd -k start !

can you help :smiley:

may i should configure another file ?!:rolleyes:

When you invoke "http" you are probably actually invoking /usr/sbin/http.

When you invoke /etc/init.d/httpd you are invoking a startup script called httpd which resides in /etc/init.d and whcih reads its configuration values from /etc/sysconfig/httpd and then calls /usr/sbin/httpd with the OPTIONS string from /etc/sysconfig/httpd.

If you look at /etc/sysconfig/httpd I am sure that you will find that the OPTIONS line is not commented out and have been set to something or other. You also might find that the HTTPD line is uncommented to invoke the worker model.

all the file lines are commented :frowning: BUT a collegue of mine, while trying to help, set in one of the configuration files, related to "apache2" i guess, ( the one i want to use ), something so that when i run /etc/init.d/httpd it will calls "apache2" instance !!!

hope it helps to understand better the problem
--------

Further more :

the file "/usr/local/apache2/conf/httpd.conf" that is used once i start apache doing "/etc/init.d/httpd -k start" ( "httpd.conf" has the value "ServerRoot "/usr/local/apache2" ); so what i should probably do is to make the command "httpd -k start" perform this "/etc/init.d/httpd -k start" INSTEAD OF CALLING THE OTHER APACHE INSTANCE.

-------

THE QUESTION IS WHERE TO CONFIGURE THE VALUE "/etc/init.d/httpd" IN THE FILE "httpd.conf" i guess ( or maybe some where else ), THAT CALLS MY RIGHT "APACHE" ( I MEAN "/etc/init.d/httpd" )

I am sorry but I can make absolutely no sense out of your last reply. Do you want two separate instances of apache to start on reboot or not?

I would like to have ONLY one istance running on my server, i mean "apache2" on reboot, and it's the one i run, when launching the script "/etc/init.d/httpd".

Sorry for being not clear in the message i left before :frowning:

A web search for "apache multiple instances" will return many hits.

For example, have a look that this post Can a server has two instances of apache httpd running using two different config files?

Thank you for Helping, but i think that i'll keep it open till someone give me an advice OR find it on my own.

I also changed the "/etc/sysconfig/httpd" file, uncommentin the Flag "OPTINS" and putting "OPTIONS=/etc/init.d/httpd -k start", but still it doesn't work after rebooting the machine !

The OPTIONS variable is there to pass options to the httpd process. Do a man httpd to learn what the various options are. You can not input a command there, as it's not requesting the command to run.

In your case, I assume that you have your Apache configuration in another location/filename than the default configuration. If so, you will want to tell the Apache process where to find this new configuration.

I suggest the following line:

OPTIONS="-f <filename>"

This will make Apache use <filename> as your configuration file.

Also, you may want to not use /etc/init.d/httpd -k start to start your Apache process. The init script takes a single command as arguments. You can type /etc/init.d/httpd to see what these commands are.

service httpd start will do the same thing.

i coppied the "httpd.conf" of the "apache2" instance i needed to use, in the directory "X" where i do have the other "httpd.conf" of the other "apache" instance, but when i do "httpd start", i get an error that calls a line in the "http.conf" and that is related to php and this is normal because only "apache2" instance was compiled taking into account php5.

i'am really desperate, because no one seems to understand what i want to do. THE ONLY THING I WANT IS TO MAKE MY APACHE2 INSTANCE THE DEFAULT APACHE INSTANCE THAT STARTS AFTER REBOOT AND CAN'T FIGURE OUT WHERE TO SET THIS ---> THAT'S THE ONLY THING I NEED TO DO AND I ALREADY TRIED MANY CONFIGURATION FILES ( such as "/etc/sysconfig/httpd" file ) WITHOUT SUCCESS

Please try to clarify the situation.

Do you have two Apache installs (as in two separate complete install in two directories, binaries and all) or do you just have two configuration files?

When you try to start Apache, what error are you getting?

I understand your frustration, but in order for us to help you need to clarify what you are trying to do.

By guessing from what you've written, it appears like you have installed a separate Apache install in another directory. In order to start this instance of Apache rather than the default instance, you will need to indicate to the startup script that Apache resides in another directory.

If this is the case, edit /etc/sysconfig/httpd and add/edit the following lines:

HTTPD=<path to new binary>
OPTIONS="-d <location of serverroot>" # Default /etc/httpd/

If that is not the case, you need to clarify what you are trying to do in a better way.

-have 2 distinct apache installed and just one of them is running at time

-it isn't a matter of having an error when starting the apache i need but a matter that: when i do "httpd start" i got the instance that i don't need running and to have the one i need i have to do "/etc/init.d/httpd -k start" AND I CAN WORK WHEN I DO THIS

I MODIFIED /etc/sysconfig/httpd FILE, CHANGING JUST

HTTPD=<path to new binary>

AND REBOOTED THE MACHINE, but it still give me an error that point that line in "httpd.config" which is :

"AddHandler php5-script ...."

which is normal as i sad before, since this apache instance was not compiled with php !!!! THAT IS ALL THE MATTER !!!!!

I understand your frustration, but if you wish for me to help you, please refrain from expressing this kind of hostile behaviour.

I'd love to help you, but please do not assume that I know what's happening on your server. In order to help you, you need to provide clear information of what is going on. What I'd like you to do is to provide the following:

  • The FULL error message you receive when starting Apache, no matter how irrelevant you may think it is.
  • The contents of your /etc/sysconfig/httpd file, WITHOUT comments (IE, do not copy lines that start with "#")
  • The location of BOTH your Apache binaries, both the old one and the new.
  • The location of the CONFIGURATION files for BOTH your Apache instances.
  • Whether you used yum install php another method to enable PHP support for Apache.
  • What version of Red Hat Enterprise Linux you are using.

The more information you can provide the better, and it will allow me as well as others to resolve your issue in a quick manner.

THANK YOU SO MUCH AND I AM REALLY SORRY BUT THIS IS QUIET FRUSTRATING ! :frowning:

As i wrote in the message before, it is not a matter of having an Error when starting Apache, but a matter of starting the right one and in this case Apache2 when doing the command "httpd start".

*) Binary directories : the Apache that starts, i mean the one that goes running when doing "httpd start", is under the dir "/etc/httpd" and the one i need is under "usr/local/apache2" and that i start doing : "/etc/init.d/httpd -k start"

*) Same directories for the configuration files adding "/conf" piece to the directories i wrote before !.

*) ENTIRE content of the file "/etc/sysconfig/httpd" is commented with '#'

*) Linux version V5

================ FIXED USING WEBMIN !!==================

I FIXED THE PROBLEM AFTER INSTALLING WEBMIN ON MY REDHAT SERVER AND DEFINING A NEW OPERATION AT START TIME IN THE MENU "System/Bootup & Shutdown" that is "/etc/init.d/httpd start" AND IT WORK !!!

THANK SO MUCH

Mehdi, I'm going to make one more attempt at trying to resolve your issue. The problem is that I need information in order to diagnose the problem, and I need ALL of the things I listed as bullet points, along with any other information you can provide. The MORE information you can give, the easier it will be to diagnose your issue.

Now... You state that you have two directories where Apache is installed. The new instance of Apache is located in /usr/local/apache2 if I understand things correctly. This directory is called your ServerRoot.

What you need to do is the following:

  • Check your /etc/sysconfig/httpd and make sure that the OPTIONS variable has a -d option that points to your serverroot. Look further up in my thread for how to do this.
  • MAKE SURE that the serverroot contains either a directory, or a symlink to a directory, containing the required modules, specifically the PHP5 module. This is EXACTLY why I asked you to supply the error message, so that I can verify if this is true or not.
  • If this does not resolve your issue, I kindly ask you to provide the information I listed in the bulletpoints in my post above. Please list ALL of said information, or I will refrain from assisting further due to lack of relevant information to diagnose your issue.

One more thing. Is there a specific requirement for having two separate instances of Apache? Specifically, did you try yum install php to enable PHP-support for your existing Apache install?

Please see Install PHP 5 in Red Hat Enterprise Linux 5 for a guide as for how to install PHP5 support on Red Hat Enterprise Linux 5.

Please avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Thank You.

The UNIX and Linux Forums