# cant start apache [Solved]

## apiaio

Today I had to change the router  TP-LINK for ZyXEL. After reboot hostname has changed from localhost to dhcppc1.  *Quote:*   

> /etc/host 
> 
> 127.0.0.1       localhost
> 
> ::1             localhost
> ...

 /etc/conf.d/hostname *Quote:*   

> hostname="localhost"
> 
> 

 and 

 *Quote:*   

> # echo $HOSTNAME
> 
> dhcppc1
> 
> 

  *Quote:*   

>  # /etc/init.d/apache2 restart
> 
>  * Starting apache2 ...
> 
>  * start-stop-daemon: failed to start `/usr/sbin/apache2'                        [ !! ]
> ...

 I have to say, that I am confused and do not know how to fix it.Last edited by apiaio on Mon Nov 23, 2015 6:04 pm; edited 1 time in total

----------

## Buffoon

Configure your DHCP client not to pull hostname from DHCP server. Or even better, do not use DHCP at all.

----------

## apiaio

Let's say solved. Apache works after editing /etc/dhdcpcd.conf  *Quote:*   

> nooption option

 

 but I am not 	absolutely satisfied. After connecting to the router HOSTAME is still dhcppcX.

I am not able  *Quote:*   

> Configure your DHCP client not to pull hostname from DHCP server.

 as Buffoon suggested. How to do that?

----------

## apiaio

Unfortunatelly  *Quote:*   

> nooption option

 is not the best solution too. E.g. after rebooting from Windows apache doesnt start. I do not know why. So that I removed apache from startup services and after reboot when I neet to use apache I run

```
sysctl kernel.hostname=localhost

/etc/init.d/apache2 start
```

But main problem, that ZyXEL assigns hostname of my comp persists.

----------

## kikko

Hi apiaio

which dhcp client are you using? There is a pretty big difference between e.g. dhclient and dhcpcd

On the other hand, you can also configure your dhcp server (the ZyXEL AP) to not push the hostname for your internal network

Regards

----------

## apiaio

Hi kikko.

Using dhcpcd. Concerning hostname I am not sure if is possible to change ZyXEL's configuration.

But I am sure that must exists the way how to ignore sent hostname. 

I have installed Sabayon, which hostname is aswell overwritten by hostname sent by server, but apache starts without any problems.

----------

## freke

Then I'd start comparing the apache-configs  :Wink: 

----------

## apiaio

 *freke wrote:*   

> Then I'd start comparing the apache-configs 

 I did, but no significant differencies found. Concerning dhcpcd config's files dhdcpcd.conf are the same and others is not compareble becouse my Gentoo uses OpenRC and SL Systemd.

----------

## kikko

Hi apiaio

you should try to start httpd daemon directly on the command line, in order to get more "valuable" output

commands are like this:

Configuration check

```
/sbin/httpd -f /etc/apache2/httpd.conf -t
```

Start

```
/sbin/httpd -f /etc/apache2/httpd.conf -k start
```

Check it, I'm not 100% sure about httpd location  :Razz: 

Regards

----------

## apiaio

Sorry kikko.

I cant locate httpd in /bin or /sbin neither Gentoo nor SL.

----------

## freke

for Gentoo that'd be /usr/sbin/apache2 instead of /usr/(s)bin/httpd

----------

## apiaio

 *Quote:*   

> dhcppc1 miro # sysctl kernel.hostname=localhost
> 
> kernel.hostname = localhost
> 
> dhcppc1 miro # /usr/sbin/apache2 -f /etc/apache2/httpd.conf -t
> ...

 

----------

## khayyam

 *apiaio wrote:*   

> I am not able "configure your DHCP client not to pull hostname from DHCP server" as Buffoon suggested. How to do that?

 

apiaio ... you would do the following:

```
dhcp_eth0="nosendhost"
```

... but that isn't really your problem, the issue is that apache can't resolve the FQDN (Fully Qualified Domain Name) ... 'localhost' isn't a FQDN but the name of the 'loopback' (127.0.0.1) ... it also isn't really your 'hostname', every machines loopback is 'localhost'.

```
hostname="foo"
```

```
127.0.0.1 foo localhost
```

```
# dig +short localhost

127.0.0.1
```

So, you either have apache 'listen' on the loopback  ... via changing apache2.conf to 'Listen 127.0.0.1:80', or you provide a FQDN in /etc/hosts, or DNS, (that matches the machines IP).

best ... khay

----------

## apiaio

Thanks, solved. But this part I dont understand  *Quote:*   

>  ... via changing apache2.conf

 Where is apache2.conf?

----------

## khayyam

 *apiaio wrote:*   

> Thanks, solved. But this part I dont understand "... via changing apache2.conf"
> 
> Where is apache2.conf?

 

apiaio ... you're welcome. Sorry, httpd.conf.

best ... khay

----------

