# Apache will not start at boot



## hollis2507 (Sep 16, 2009)

Hi all, 

I am new to BSD and have recently installed apache, mysql, php and joomla. My problem is with apache. I have installed apache13 which is running fine although I can't get it to start when the system boots. I can start apache manually with /usr/local/sbin/apachectl start and this works fine. 

I have put: 

```
apache_enable="YES" 
mysql_enable="YES"
```
into rc.conf which starts mysql but not apache. 

I have also used dmesg -a | less and cannot see any sign of apache attempting to start. 

May the problem be that I am using PCBSD as I have read that this does not start programs in the same way as Freebsd? In this case what would be the solution? 

Thanks in advance.


----------



## DutchDaemon (Sep 16, 2009)

What is the output of [cmd=]/usr/local/etc/rc.d/apache rcvar[/cmd]?


----------



## hollis2507 (Sep 16, 2009)

Thanks for the quick response. 

Just for info the output of that was


```
#apache
apache_enable=YES
```

Even so I have since posting, managed to fix the problem. 

To do this is entered

[cmd=]/usr/local/sbin/apachectl start [/cmd]

into

/etc/rc.local

It now runs this during the starting local daemons, during the boot up and apache seems to work fine. 

Thanks for you help anyways


----------



## DutchDaemon (Sep 16, 2009)

But, strictly speaking, that setting in /etc/rc.conf should run [cmd=]/usr/local/etc/rc.d/apache start[/cmd]. Can you check whether that command works or not? That's how the starting at boot-time should work.


----------



## hollis2507 (Sep 16, 2009)

I run that and it did start apache. 

Obviously what i have in rc.conf is not running that command. Is there anything else i should put other than apache_enable="YES". Or is the problem else where?  

Is the way i've done it not the corrent way then?


----------



## DutchDaemon (Sep 16, 2009)

No, /etc/rc.local should really only be used for stuff that cannot be started in any other way. It's more or less a deprecated way of doing things on FreeBSD.

For the record: [cmd=]/usr/local/etc/rc.d/apache start[/cmd] will *not* start Apache if the information in /etc/rc.conf (i.e. 'apache_enable="YES"') is incorrect .. so Apache should really start at boot time.

You could check the output of [cmd=]dmesg -a[/cmd] (all the way at the end, where daemons are started) to see if there's something about Apache not being able to start. Normally one would see:


```
Performing sanity check on apache22 configuration:
Syntax OK
```


----------



## hollis2507 (Sep 17, 2009)

Will using rc.local to start it potentcially cause me problems in the future then? 

I have removed the line from rc.local and run dmesg -a and there appears to be no sign of apache starting. 

Althought it does still start when i manually run /usr/local/etc/rc.d/apache start so from what you say, the information in rc.conf should be correct. 

Is there anything else i can try?


----------



## DutchDaemon (Sep 17, 2009)

Using /etc/rc.local is not _illegal_  It's just kind of a last resort solution, if all else fails. And the automatic start-up of Apache should not fail with your settings. Can you post your rc.conf and the last 20-or-so lines of [cmd=]dmesg -a[/cmd] (the stuff after 'Starting local daemons:'?


----------



## hollis2507 (Sep 17, 2009)

At least I no i can get it working if nothing else does!

My rc.conf file is as follows: 


```
background_dhclient="YES"                        
compat5x_enable="YES"                            
sshd_enable="YES"                                
usbd_enable="YES"                                
httpd_enable="YES"                               
apache_enable="YES"                              
mysql_enable="YES"                               

# Disable Moused by default. Xorg sets up the mouse automatically, and moused can conflict with it.
moused_type="auto"                                                                                 
moused_enable="YES"                                                                                

devd_enable="YES" 
devfs_system_ruleset="devfsrules_common" 
sendmail_enable="NO"                     
sendmail_rebuild_aliases="YES"           
ldconfig_paths="/usr/lib/compat /usr/local/lib /usr/local/kde4/lib /usr/local/lib/compat/pkg"

# Enable the pcbsd startup / shutdown scripts
pcbsdinit_enable="YES"                       
                                             
#Enable samba server                         
samba_enable="YES"                           
                                             
# Disable LPD                                
lpd_enable="NO"                              
                                             
# Enable CUPS                                
cupsd_enable="YES"                           
linux_enable="YES"                           
                                             
# FSCK Enhancements                          
fsck_y_enable="YES"                          
background_fsck="NO"                         
                                             
# tmpmfs Flags                               
tmpmfs="YES"                                 
tmpsize="800m"                               
tmpmfs_flags="-S"                            
clear_tmp="YES"                              
                                             
# Denyhosts Startup                          
denyhosts_enable="YES"                       

# powerd: adaptive speed while on AC power, adaptive while on battery power
powerd_enable="YES"                                                        
powerd_flags="-a adaptive -b adaptive" # set CPU frequency                 

# enable HALd 
dbus_enable="YES"
polkitd_enable="YES"
hald_enable="YES"

# Enables support for HPLIP
hpiod_enable="NO"
hpssd_enable="NO"


# ntpdate is deprecated and will eventually be removed from the distribution since
# the same functionality is available in ntpd(8).
# Without "ntpd_sync_on_start" option, ntpd refuses to perform an
# initial correction if the clock offset is too large.
#
ntpd_sync_on_start="YES"

# Enable the firewall
pf_rules="/etc/pf.conf"
pf_enable="YES"
pf_flags=""

# Enable ipfw and open it by default since we have PF
firewall_enable="YES"
firewall_type="open"

snddetect_enable="YES"
mixer_enable="YES"
hostname="pcbsd"
ifconfig_em0="inet 198.106.74.2 netmask 255.255.255.252"
defaultrouter="198.106.74.1"
```

The results of dmesg -a are as follows: 


```
Starting nmbd.                                                                                      
Starting smbd.                                                                                      
Starting local daemons:                                                                             
.                                                                                                   
Updating motd                                                                                       
.                                                                                                   
Mounting late file systems:                                                                         
.                                                                                                   
Starting powerd.                                                                                    
Starting mysql.                                                                                     
Starting default moused:                                                                            
moused:                                                                                             
unable to open /dev/psm0: No such file or directory                                                 

.
Starting dbus.
Starting hald.
Starting denyhosts.
Configuring syscons:
 blanktime          
.                   
Starting sshd.
```

Just for your information, I am invloved in running an internal test network in which we have 4 machines running PCBSD all of which have apache1.3 running and all seem to have to same problem so i assume it is something that we have missed during the installation if that helps at all. 

Thanks again for the help.


----------



## DutchDaemon (Sep 17, 2009)

Still nothing wrong, as far as I can see ...

Final attempt: can you post the output of

[cmd=]rcorder /etc/rc.d/* /usr/local/etc/rc.d/* | grep -A 5 -B 5 apache[/cmd]?


----------



## Base (Sep 17, 2009)

Check your hostname and set it correct.
ex. 
	
	



```
hostname -s localhost.net
```


----------



## overmind (Sep 17, 2009)

Do you have installed apache 1.x ?
Because if you have apache 22, the script from /usr/local/etc/rc.d is apache22, not just apache.


----------



## DutchDaemon (Sep 17, 2009)

Read the first post, overmind.


----------



## hollis2507 (Sep 18, 2009)

The output of rcorder /etc/rc.d/* /usr/local/etc/rc.d/* | grep -A 5 -B 5 apache was: 



> /etc/rc.d/timed
> /etc/rc.d/ugidfw
> /etc/rc.d/yppasswdd
> /etc/rc.d/LOGIN
> ...



Plus the host name is set to localhost or do i need to add localhost.net?


----------



## DutchDaemon (Sep 18, 2009)

If Apache doesn't complain about a hostname on startup, you're usually fine. The fact that you can start Apache manually seems to suggest that there's no problem in that area.

I see in your rcorder output that Apache is included in the start-up sequence, and in a normal location (after mysql). Why it doesn't get started or doesn't even turn up in dmesg -a is beyond me ..


----------



## hollis2507 (Sep 18, 2009)

This is why I was soo confused. All the forums and various things I have read tell me that what I am doing should work. 

Thanks for you help anyways. Its much appreciated.


----------



## unixeagle (Sep 19, 2009)

How did you install Apache 1.3? Using FreeBSD ports or PBI file?

Can you try to replace:


```
apache_enable="YES"
```

with


```
apache22_enable="YES"
```

and please let me know if it worked for you.


----------



## hollis2507 (Sep 19, 2009)

I installed apache1.3 through the ports. 

Isn't 


> apache22_enable="YES"


used for apache2.2 or should i still try it anyways?


----------



## DutchDaemon (Sep 19, 2009)

[cmd=]httpd -v[/cmd] will tell you the version. But you already showed that [cmd=]/usr/local/etc/rc.d/apache start[/cmd] starts Apache, so why people keep suggesting apache22 is not known to me.


----------



## hollis2507 (Sep 22, 2009)

As so many people were saying to try apache22_enable="YES" I have tried it and this does not work either...


----------



## DutchDaemon (Sep 22, 2009)

Of course not. I would have eaten your hat if it _had_ worked.


----------



## CodeBlock (Sep 22, 2009)

Yeah apache22_enable was my first thought then I re-read the first post and knew that wasn't it. A valid question is why *not* use apache 2.2? Another would be have you checked logs? See if /var/log/messages has anything maybe? Just some ideas, not trying to get on you if you have a real reason to use 1.x, but if not maybe give 2.2 a shot.


----------



## unixeagle (Sep 23, 2009)

Good for you that you tried apache22_enable, and it's bad that it didn't work.

I'm sure that Apache 1.x should have apache_enable rcvar, and it is not apache22. So, why I asked you to try apache22? You may ask. The answer is simple:

Sometimes you have to try irrational approaches to solve your problem, especially when you had walked all the way with the documentation and common sense, this is better than saying "I will not try this, if I do I will look like a fool". No you will not, you have to experiment all rational and irrational solutions. This is how you will get experience, this is how you will learn.

When I found that DutchDaemon had verified all common causes to your problem with no luck in solving it, I found it reasonable to start thinking different.

I think DutchDaemon and all others had made a good job troubleshooting your problem.

As for your problem, I think, IMHO, that the cause of it is related to how PCBSD registers it's installed packages. I could not find any useful information in the PCBSD documentation. You are dealing with a non-standard FreeBSD version, and this comes with a price.
I suggest you use the official FreeBSD version instead.

Good Luck.


----------

