Freebsd – How to configure hostname for `apache22` package on FreeBSD

apache-2.2configurationfreebsdhostname

I'm configuring development & test FreeBSD machine on VM.
I installed apache22 package and restarted. But the daemon does not started with this error:

%apachectl start
httpd: apr_sockaddr_info_get() failed for test.box
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

My hostname is test.box. Because this is temporary test box, it has no real domain-name. But I used 2-level name to avoid long time waiting of sshd on booting.

However, I searched web, and I modified /etc/hosts file like this (I didn't touches this file before):

# This is original configuration
#::1                    localhost localhost.my.domain
#127.0.0.1              localhost localhost.my.domain

# New configuration    
::1                     localhost test.box
127.0.0.1               localhost test.box
127.0.0.1               test.box test

Now apache fails with this error message:

%apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName
(13)Permission denied: make_sock: could not bind to address [::]:80
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
%

I don't know what's required now. Please let me know reason and solution of this error.

—- (edit) —-

The permission errors are caused from omission of sudo.

Best Answer

httpd: Could not reliably determine the server's fully qualified domain name, using test.box for ServerName

Usually, this is just a warning and not a fatal error. It can be solved by adding the config to your apache2.conf file.

ServerName yourserver.yourdomain.com

I can see there is a permission denied error. Make sure you invoke the startup scripts as super user root. Also, make sure there is no other process already listening on apache port (default 80).