# Why does init.d/apache2 require net?

## pizzach

I don't always have a wireless connection on my laptop and sometimes I like to use my computer to show clients specific webpages on my local hard drive.  Since they use PHP, I have no choice and have to have a web server running to parse the code.

Once I removed the requirement for net from /etc/init.d/apache2, all has become fine.  Shouldn't apache start up fine anyway as long as net.lo is running?  I mean, the loopback device is why you can use localhost etc to connect to yourself right?  It just doesn't lead to the outside world.

----------

## John R. Graham

Probably more than 99% of all Apache deployments serve web pages off of localhost, so requiring net is the more correct implementation for the vast majority of users.  You've discovered the correct modified solution for your particular case, so all is well with the world.    :Smile: 

- John

----------

## Hu

 *pizzach wrote:*   

> Shouldn't apache start up fine anyway as long as net.lo is running?  I mean, the loopback device is why you can use localhost etc to connect to yourself right?

 Not necessarily.  Apache needs to be able to bind to its specified listen addresses when it starts.  If you have configured it to listen to a specific non-loopback address, then Apache cannot start until some interface is configured with that address.  Hence, Apache cannot start until the initscript for that interface has run.  In theory, the Apache initscript could be enhanced to examine the Apache configuration file and choose either need net or need net.interface, depending on whether Apache has a wildcard/loopback bind or a specific non-loopback bind.  However, Apache configuration files are complicated, so it might be easier just to move that to a variable in /etc/conf.d/apache2 and let the administrator set it properly for his site.

----------

## pizzach

Sorry guys.  Let me try to be clear about what I think it wrong.  Shouldn't net.lo be sufficient to start apache2/vsftpd etc when the init.d script has net required?  I think I am either missing something, or that may be a bug in gentoo marked as a feature.

----------

## broken_chaos

Have you set RC_NET_STRICT_CHECKING="lo" in /etc/conf.d/rc (if using baselayout-1)?

If you're using baselayout-2/openrc, you might be able to set rc_apache2_need="!net" in /etc/rc.conf to accomplish the same thing as you've already done, without editing the init.d script.

----------

## Hu

 *pizzach wrote:*   

> Let me try to be clear about what I think it wrong.  Shouldn't net.lo be sufficient to start apache2/vsftpd etc when the init.d script has net required?  I think I am either missing something, or that may be a bug in gentoo marked as a feature.

 I understand exactly what you want, and I am saying that it is configured the way it is because for most users, the shipped behavior is correct.  Your need to run a webserver without offering service to any other machines, although not unpredecented, is atypical.  Configuring the system as you have done allows the initscript to start Apache at a time when, for a more typical configuration, functionality required by Apache would not be available, resulting in a startup failure.  For your use case, starting net.lo is adequate, but the initscript currently has no way to recognize that, so it requests the more complete functionality offered by bringing up a non-loopback interface.

As broken_chaos notes, there are configuration settings you can use to affect this without modifying the initscript.  I grant that the support for your particular situation is not as simple as it could be.  I think the developers would be willing to accept patches to improve that support, if the patches were well written and free of negative side effects.  I think that the relatively rare nature of your use case results in a lack of interest in improving that support on the hope that someone might find it useful.

----------

