# System doesn't see rc.conf



## Demontager (Dec 20, 2012)

I met strange error when was triyng to restart apache22 on FreeBSD 9 -


```
Cannot 'start' apache. Set apache enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'
```
/etc/rc.conf exists and apache22 already enabled. And then I tried to restart postgresql same warning -


```
/usr/local/etc/rc.d/postgresql start
Cannot 'start' postgresql. Set postgresql_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'.
```

It looks like system can't read rc.conf. Permissions set to 644.

I'm very confused seems like simple error, but not so obvious for me.


----------



## phoenix (Dec 20, 2012)

Post your rc.conf.

Or run it manually through sh(1) with the *-x* option:
`# sh -x /usr/local/etc/rc.d/apache22 start`

And, check the output of the *rcvar* option:
`# service apache22 rcvar`


----------



## nakal (Dec 20, 2012)

This can happen, if your line endings are not typical for Unix. Load the file into vim, type:

```
:set fileformat=unix
:wq
```


----------



## UNIXgod (Dec 20, 2012)

Demontager said:
			
		

> I met strange error when was triyng to restart apache2 on FreeBSD 9 -
> 
> 
> ```
> ...



Is your routing adresses set up in your httpd.conf and pg_hba.conf


----------



## Demontager (Dec 20, 2012)

rc.conf

```
hostname="myserver.com"
sshd_enable="YES"
sendmail_enable="NONE"
zfs_enable="YES"
#ntpd_enable="YES"
ifconfig_re0="inet 78.47.xxx.xxx netmask 255.255.255.240"
defaultrouter="78.47.xxx.xxx"
apache22_enable="YES"
nginx_enable="YES"
mysql_enable="YES"
#memcached_enable="YES"
#memcached_flags="-l 127.0.0.1"
nginx_enable="YES"
# Mail Server
#exim_enable="YES"
# Dovecot
#dovecot_enable="YES"
#FTP
vsftpd_enable="YES"
#postgresql_enable="YES"
munin_node_enable="YES"
```
Tried to start sh -x /usr/local/etc/rc.d/apache22 start same erro appeared at bottom.
Also set as nakal told 


```
:set fileformat=unix
:wq
```
Doesn't work


----------



## Demontager (Dec 20, 2012)

at least it can see rc.conf. I uncommented   postgresql_enable="YES"

```
/usr/local/etc/rc.d/postgresql start
/usr/local/etc/rc.d/postgresql: WARNING: $postgresql_enable is not set properly - see rc.conf(5).
```


----------



## Demontager (Dec 22, 2012)

*Resolved.*
I recreated rc.conf and pasted all entries manually.


----------



## LordInateur (Jan 1, 2013)

What are the contents of /etc/hosts ? I know sometimes Apache won't start if you don't have your hostname properly set in that file. I struggled with that problem on my server for about a week, lol.


----------



## LordInateur (Jan 1, 2013)

CMonster95 said:
			
		

> What are the contents of /etc/hosts ? I know sometimes Apache won't start if you don't have your hostname properly set in that file. I struggled with that problem on my server for about a week, lol.



Sorry didn't see the "resolved" tag.


----------



## Demontager (Jan 2, 2013)

No, the problem was not in apache, any service described in rc.conf was unable to restart. I think i put some russian character in rc.conf and that caused misspelled config.
Recreation of rc.conf from scratch did the trick.


----------

