3

I compiled Apache and PHP from source on a RedHat server, but in doing that, I forget to install the httpd as service.

Files used to compile Apache 2.4.7

files to compile apache 2.4.7

Command used to compile Apache 2.4.7

./configure --prefix=/etc/apache247 --with-included-apr --with-pcre --enable-so --enable-rewrite=shared --with-layout=Apache --enable-modules=most --enable-mods-shared=all;

Directory of Apache 2.4.7

apache 2.4.7 directory

Script of init.d to start Apache 2.4.7

I found this script in stackoverflow. It's not mine and not official.

Some users have told me that there is a script in the apache folder, but I have not found.

init.d apache script

If you prefer the text:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          apache247
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: apache247
# Description: Start apache247
### END INIT INFO

case "$1" in
start)
        echo "Starting Apache ..."
        # Change the location to your specific location
        /etc/apache247/bin/apachectl start
;;
stop)
        echo "Stopping Apache ..."
        # Change the location to your specific location
        /etc/apache247/bin/apachectl stop
;;
graceful)
        echo "Restarting Apache gracefully..."
        # Change the location to your specific location
        /etc/apache247/bin/apachectl graceful
;;
restart)
        echo "Restarting Apache ..."
        # Change the location to your specific location
        /etc/apache247/bin/apachectl restart
;;
*)
        echo "Usage: '$0' {start|stop|restart|graceful}"
        exit 64
;;
esac
exit 0

ntsysv

I use this command to check the services on RedHat. So, I put the init.d script in the correctly folder - /etc/init.d/ - but the apache2 script not appear here.

enter image description here

And after I restart the server, apache was not started automatically.

So, whats wrong?

I don't know in what log I get this errors of startup scripts.


Patrick Maciel
  • 143
  • 1
  • 8
  • 2
    Is there a good reason why you've compiled from source? – MadHatter Apr 29 '14 at 14:01
  • 2
    http://developerblog.redhat.com/2013/10/24/apache-httpd-2-4-on-red-hat-enterprise-linux-6/ – user9517 Apr 29 '14 at 14:03
  • Have you looked in your logs to see if there are any relevant messages ? – user9517 Apr 29 '14 at 14:04
  • Is... is it `chkconfig`'d on? Are the paths to the binary correct? If you run `service apache247 start` do you get any errors? – Aaron Copley Apr 29 '14 at 14:11
  • @MadHatter The core team can't install using a repo and threw the problem so I did it ... (obs.: I'm not a server administrator, I'm a developer with knowledge in linux servers. – Patrick Maciel Apr 29 '14 at 14:16
  • @Iain Thanks for the link my friend, I'll try do that (but I need the apache 2.4.9, because I check the 2.4.6 version has some vulnerabilities). – Patrick Maciel Apr 29 '14 at 14:19
  • @Iain what logs? apache logs? If not, what command I need to run? – Patrick Maciel Apr 29 '14 at 14:20
  • @AaronCopley If I run the command everything is works very well. But I can't find the service in `ntsysv` command to set automatically. – Patrick Maciel Apr 29 '14 at 14:22
  • For my money, I'd ask about getting the repo install to work before going for a compile-from-source; there's no end to the maintenance overhead that will cause. On a separate note, I didn't downvote, but mouse over the down arrow; the popup says "*This question does not show any research effort; it is unclear or not useful*". Downvotes without comment may be presumed to be for at least one of those reasons. – MadHatter Apr 29 '14 at 14:23
  • I downvoted your question because you failed to provide any useful information, particularly in the form of log snippets. I've now VTC your question for failing to have a minimal understanding of the problem because quiet frankly not knowing where to look for logs is ... – user9517 Apr 29 '14 at 14:24
  • 1
    `chkconfig --add apache247 && chkconfig apache247 on` – Aaron Copley Apr 29 '14 at 14:28
  • @Iain I have provided all the information I have. If no have more information, is because I have not, or do not know how to get. So, that's is a not reason for down vote. Now if I said just: "How I do it?" And did not explain what I tried to do, would be another story. – Patrick Maciel Apr 29 '14 at 15:55
  • @MadHatter About maintain I agreed with you. But when I try to find the repo with apache 2.4.6+ I not found, so I compiled. – Patrick Maciel Apr 29 '14 at 15:56
  • 1
    @AaronCopley It's works my friend, please write an answer for me please. – Patrick Maciel Apr 29 '14 at 15:59
  • @MadHatter Anyway, this is a homologation server. Not the official. I'll replace this apache for the any repo with 2.4.9+. Thanks – Patrick Maciel Apr 29 '14 at 16:02
  • Honestly, Patrick, that's a pretty fair answer, and a pretty good reason. I still don't understand why you need apache 2.4, but if you do, given that you also need PHP, I can't fault your approach. – MadHatter Apr 29 '14 at 16:10
  • @MadHatter I just want to work with the recently version of every technology/service/language/framework. Just that. Not other reason. And, I want to use that because in my machine I use too, and avoids conflicts / future problems like: on my computer worked, but the version on the server is different; AND, the 2.4.6 version have some problemas, and 2.4.9 fix all problems (and get news :P) – Patrick Maciel Apr 29 '14 at 17:10
  • 2
    That is a **very poor reason indeed** to stop using the distro versions, which are kept fully-patched as long as the distro remains in-life. – MadHatter Apr 29 '14 at 17:39
  • **Off-topic is too much for me.** Anyway, I edit my question. So, tell me if it's good now or if I need put more details. – Patrick Maciel Apr 30 '14 at 13:40
  • @MadHatter I agreed with you, but as I said: I'm not a unix administrator, or expert in servers. I'm just a developer and in my knownledge compile from source or use the last version is not a "evil thing" is just an option. About **distro versions** think about: RedHat and Ubuntu/Debian using the incredible old version of apache (2.2.15) and php (5.3.3). Why? It's stable? Just that? So I can't use the recently PHP features because the server think is not a good idea? Just that? Explain for me please. – Patrick Maciel Apr 30 '14 at 13:56
  • RedHat explain this policy themselves [here](https://access.redhat.com/site/security/updates/backporting/?sc_cid=3093), but in essence it boils down to "*stability is a really good thing in production systems*". That you don't get that is, I'm afraid, one of the big red flags for me that mark this as not being a professional sysadmin question. – MadHatter Apr 30 '14 at 13:59
  • I'm not a professional sysadmin, I'm a developer posting server question in serverfault. But you not explain for me (I'm really asking you, is not a joke.), anyway thanks for you support. – Patrick Maciel Apr 30 '14 at 15:10
  • Did you read the link? – MadHatter May 01 '14 at 07:12

2 Answers2

1

Is apache installed in /etc/apache247/bin/apachectl ?

Because that script its looking into apache on that folder.

If it is not installed on that path, just edit the init file to point it to the right folder.

Trinue
  • 116
  • 3
  • Where is the script? In what folder in `/etc/apache247/`? – Patrick Maciel Apr 29 '14 at 15:59
  • Ohhh, I see: the `apachectl` is the script right? – Patrick Maciel Apr 29 '14 at 16:01
  • The script you posted is named apache2 and as you told earlier you put that script into the `/etc/init.d` folder with 755 permissions. If you read analize the file you posted, you will see that it tells you to edit the path to the apachectl binary file. I was asking you if you know if that file actually exists in the `/etc/apache247/bin` folder. If it doesn´t exist, you must point the script to the correct location of the file. – Trinue Apr 29 '14 at 16:13
  • The script I posted I found in stackoverflow, is not the same of `/etc/apache247/bin/apachectl`. – Patrick Maciel Apr 29 '14 at 16:34
  • I try use the script of `apachectl` or `httpd` in the `bin` folder, but `chkconfig` not accetped. – Patrick Maciel Apr 29 '14 at 16:41
  • I think you don´t understand what i am saying. The script you posted is fine, the only thing you need to be sure is that the `/etc/apache247/bin/apachectl` file actually exists and its located in that folder because this script tries to run that file. – Trinue Apr 29 '14 at 18:36
  • Oh, sorry. Yes, this file exists. – Patrick Maciel Apr 30 '14 at 15:07
1

It sounded like you needed to register the init script with chkconfig --add apache247. You can then mark it as 'on' for the default run-levels with chkconfig apache247 on. A reboot should verify this will work as expected.

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68