0

I want my compiled apache2 server to run when my OpenSuse 12.3 server boots.

I've followed the procedure listed in How do I get apache to startup at bootime on Linux, namely:

  • Creating the file /etc/init.d/apache2

  • Adding it to the services with

    chkconfig --add apache2

I can see it listed in YaST's runlevel manager (not sure about the exact name as my distro is in spanish) as

apache2 Yes*

I take it that this means that the service is configured to start at boot but isn't running when I check.

The content of my /etc/init.d/apache2 is:

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:       apache2
# Default-Start:  3 5
# Description:    Controlar el servidor apache2
### END INIT INFO

/home/servidor/apache/bin/apachectl $@

I've tried changing the file's permissions, enabling the service through systemd and pretty much everything I've found online to no avail:

systemctl start apache2.service
systemctl enable apache2.service
chkconfig apache2 on

Any help would be greatly appreciated.

Edit

My custom service finally worked. After a reboot I executed

journalctl -n 

and realized that while the service was executing correctly after booting was done (via manual input in the terminal), running it during boot returned a failed status.

systemctl status apache2.service 

showed an issue with sockets not being open, so I googled the error and consequently changed my httpd.conf from

Listen 192.168.9.69:80

to

Listen *:80

Maybe the error arises because the IP adresses had not being assigned at that point? Anyway, that solved it.

Thank you very much for you interest and time.

jml
  • 9
  • 3
  • What is the output of chkconfig --list apache2? – JasonAzze May 28 '13 at 19:41
  • 1
    Does your init script actually work if you try to run it manually? – Cian May 28 '13 at 19:42
  • @JasonAzze: The output of the command is `Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd onfiguration.` `apache2 0:off 1:off 2:off 3:on 4:off 5:on 6:off` Cian, when I run `service apache2 start` the server starts normally. – jml May 28 '13 at 20:12

1 Answers1

2

First of all, /home/servidor/apache is not an adequate path for an executable in a server. Use the /usr/local hierarchy for locally compiled packages. That is the default option, you should not change it.

With regards to the init script, adapt the one distributed with your distro to your needs. Just download the RPM and extract the /etc/init.d/apache2 file.

dawud
  • 14,918
  • 3
  • 41
  • 61
  • Thank you for your answer and interest. Are there any other benefits from installing on the default location other than using the preconfigured resources of the distribution? I tried to get the `etc/init.d/apache2` file included in the RPM but it references way too many files that are not present in my machine (due to compiling apache from source) My script does work with the services panel, though. How can I check what's making it not work? – jml May 28 '13 at 21:02
  • @jml OpenSuse ships apache 2.4.3, which is a very recent version. Why do you need to compile your own instead of installing the distributed package? – dawud May 28 '13 at 21:22
  • YaST2 only showed me the 2.2 package and I needed >2.4. I must have read somewhere that the repo wouldn't be updated until the next OpenSUSE release so I decided to compile without searching further (noobish mistake there). Is there any hope for my current install or do I have to wipe all and install from a repo? Ty :) – jml May 28 '13 at 21:27