Apache install issues

As I'm working down my list of ports to install I get to the Apache/PHP/MySQL part this morning thinking to myself "this can't be too hard", I think I was wrong. I've used the search function and I've used multiple search engines and I still haven't found a answer.

I made some changes to the httpd.conf file, mainly ServerAdmin & ServerName, and when I went to restart Apache with #apachectl graceful I get the following error, httpd not running, trying to start. Doesn't seem like a huge thing but for the life of me I can't figure out what to do about it. Anyone have any ideas?

Thanks
 
check your /var/log/ for http errors there. there might be more info. this can be many different reasons. make sure your /etc/hosts file info match /etc/rc.conf info, sometimes apache refused to start when they do not match. change one thing at a time and restart apache, and backup your working httpd.conf, so you can find the bugs easier.
 
use the /usr/local/etc/rc.d/apache2 script to start stop the service (like all other userland software).
Inside this startscript are more instructions you have to follow.

Code:
# Add the following lines to /etc/rc.conf to enable apache2:
# apache2_enable (bool):      Set to "NO" by default.
#                             Set it to "YES" to enable apache2
# apache2_profiles (str):     Set to "" by default.
#                              Define your profiles here.
# apache2ssl_enable (bool):   Set to "NO" by default.
#                             Set it to "YES" to start apache with SSL
#                             (if <IfDefined SSL> exists in httpd.conf)
# apache2limits_enable (bool):Set to "NO" by default.
#                             Set it to yes to run `limits $limits_args`
#                             just before apache starts.
# apache2_flags (str):        Set to "" by default.
#                             Extra flags passed to start command.
# apache2limits_args (str):   Default to "-e -C daemon"
#                             Arguments of pre-start limits run.

start the apache:

Code:
/usr/local/etc/rc.d/apache2 start

use:

Code:
apachectl configtest
to make a syntax check on the configuration

and

Code:
apachectl graceful
to restart the apache with the changes in the configfile (some changes need instead to stop and restart the apache) but without disrupting present connections.

edit:

and ofc take a look at the error log.
 
This may seem silly, but...

Did you put apache in your /etc/rc.conf file? For example, mine says:
Code:
apache22_enable="YES"

Yours may be different... but apache will not start without that line.

Edit: Apologies, I totally ignored 'User23's post right above mine.
 
cajunman4life said:
Code:
apache22_enable="YES"

Yours may be different... but apache will not start without that line.

Not absolutely. You can run service by hand, although it isn't enabled in /etc/rc.conf or /etc/rc.conf.local.

From rc(8)
Each script is expected to support at least the following arguments, which are automatically supported if it uses the run_rc_command() function:

start
Start the service. This should check that the service is to be started as specified by rc.conf(5). Also checks if the service is already running and refuses to start if it is. This latter check is not performed by standard FreeBSD scripts if the system is starting directly to multi-user mode, to speed up the boot process. If forcestart is given, ignore the rc.conf(5) check and start anyway.
[...]​
 
User23 said:
start the apache:

Code:
/usr/local/etc/rc.d/apache2 start

Tried this and I got the following
Code:
Performing sanity check on apache22 configuration:
Syntax OK
Starting apache22
/usr/local/etc/rc.d/apache22: WARNING: failed to start apache22

I then tried this just to see what the outcome would be
User23 said:
use:

Code:
apachectl configtest
to make a syntax check on the configuration

It told me
Code:
 Syntax OK


cajunman4life said:
This may seem silly, but...

Did you put apache in your /etc/rc.conf file? For example, mine says:
Code:
apache22_enable="YES"

Yours may be different... but apache will not start without that line.
I do have that line in my rc.conf file, that was one of my first things to check. I find sometimes the little obvious things are the ones that jam me up the most.

beesatmsu said:
check your /var/log/ for http errors there. there might be more info. this can be many different reasons. make sure your /etc/hosts file info match /etc/rc.conf info, sometimes apache refused to start when they do not match. change one thing at a time and restart apache, and backup your working httpd.conf, so you can find the bugs easier.
I've gone ahead and checked to make sure both files match. I added my IP address into the hosts file to match it up with the rc.conf file. This is what I had
Code:
::1            localhost localhost.my.domain
127.0.0.1            localhost localhost.my.domain
This is what I now have
Code:
::1            localhost localhost.192.168.8.9
127.0.0.1            localhost localhost.192.168.8.9
I inserted the IP in place of the my.domain as per the instructions in the hosts file. Is this the right way to do it?
 
httpd is usually started as root, additionally non-root users aren't usually available to bind to ports under 1024 (if I recall number right). If you're trying to start apache as normal user, it will fails.

You can try to run apache in debug mode on foreground
# httpd -X -f /path/to/your/httpd.conf

Check /var/log/messages

Check instruction ErrorLog in your httpd configuration for name of error log file (usually /var/log/error_log and examine this file.

You may rise logging level using instruction LogLevel in your httpd configuration file. Use value Info or Debug.
 
hansonian said:
This is what I now have
Code:
::1            localhost localhost.192.168.8.9
127.0.0.1            localhost localhost.192.168.8.9
I inserted the IP in place of the my.domain as per the instructions in the hosts file. Is this the right way to do it?

This is wrong. You try to mix the IP with domainname. If your host have the IP 192.168.8.9 it have to look like this:

Code:
 ::1 localhost localhost.my.domain
127.0.0.1 localhost localhost.my.domain
192.168.8.9 myhost myhost.my.domain
 
hansonian said:
Code:
Starting apache22
/usr/local/etc/rc.d/apache22: WARNING: failed to start apache22

The default apache error log should be /var/log/httpd-error.log if you dont already changed it in the apache config like ondra_knezour told.

--

You said
I made some changes to the httpd.conf file, mainly ServerAdmin & ServerName, ...
What else you have changed? Maybe it is a good idea to start again with an untouched apache config. Especially the apache config will not excuse you any errors.
 
If your apache isn't still working, I'm recommending to follow this path:
  1. Revert all chanes done to config files, especially to /etc/rc.conf and /etc/hosts
  2. Backup yours apache config, if you consider it important and remove directory /usr/local/etc/apache*
  3. As root update your ports tree # portsnap fetch update (portsnap is included in FreeBSD base system from 6.0 release)
  4. # cd /usr/ports/www/apache22 && make clean && make install if installations fails stating apache is already instaled, use # make deinstall && make reinstall instead make install part of command
  5. Start apache by # /usr/local/etc/rc.d/apache22 forcestart
  6. Test, that apache is running by visiting IP of your webserver with browser
  7. You can see if there are running some httpd instances by issuing command
    # ps xa | grep httpd I'm not sure, if -a option is working for normal user, so run it as root. For me here, be member of wheel group is sufficient.

All commands with prompt starting with # sign are meant to be run as root user.

If you will have still problems with starting apache, add content of following files to your next post
  • /etc/make.conf if exists
  • /etc/rc.conf
  • /etc/rc.conf.local if exists
  • /etc/resolv.conf
  • /etc/hosts
  • /etc/hosts.allow
  • Everything under /usr/local/etc/apache22/

and output of following commands
  • % ifconfig -a
  • % netstat -r

Also try describe in detail, how you're trying to connect to your webserver. For example
  • I'm using command % links [url]http://localhost/[/url] from server where apache is running,
  • I'm trying to connect from Mozilla Firefox from computer, which runs on same network segment as webserver etc.

Make sure, that you don't have set any proxy servers in your browser config.
 
after putting this on the back burner for a solid week i've gone ahead and made a clean install of freebsd and i'm going to start all over. i'm going to go back over everything here before attempting to get apache up and running again. it's a bit frustrating because all i need is apache, mysql and php on this machine and i'm having to spend more time than i thought on it. i'll mark it up as a learning exercise and hopefully get it right this time. thanks to all for the input.
 
After my clean install of FreeBSD I've installed Apache again. I still can't get it to work properly so I've listed below everything I've done in the exact order and hopefully someone will see something I've overlooked. I do think I'm heading in the right direction more so this time than the previous time.

I installed using this
Code:
# cd /usr/ports/www/apache22
# make install

I updated /etc/rc.conf with the "apache22_enable="YES"

I edited /usr/local/etc/apache22/httpd.conf and added "Servername 192.168.4.9:80 (since this is the IP of the machine itself)

I then used
Code:
kldload accf_httpmodule
to load the accf_http module. I saw this on a how-to and thought it might help with my problems, it may or may not I don't know. After this I edited /boot/loader.conf to add "accf_http_load="YES".

When I run
Code:
apachectl start
it doesn't error out and if I run
Code:
 apachectl configtest
it tells me 'Syntax OK'. I'm going to assume I have everything installed correctly this time around. However, when I open my web browser (in this case Konqueror) and direct it to either 'http://localhost' or 'http://127.0.0.1' it gives me a 'Connection to Server Refused' error.

Here's a list of my current configuration so maybe someone can see what I'm missing and point me in the right direction on this.
Code:
ifconfig
vr0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
     options-2808<VLAN_MTU,WOL_UCAST,WOL_MAGIC>
     ether 00:11:2f:03:d3:e5
     inet 192.168.4.9 netmask 0xffffff00 broadcast 192.168.4.255
     media: Ethernet autoselect (100baseTX <full-duplex>)
     status: active
plip0: flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> metric 0 mtu 1500
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 fe80::1%1o0 prefixlen 64 scopeid 0x3
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff0000000

/etc/make.conf
added by use.perl 2010-05-12 11:34:10
PERL_VERSION=5.8.9

/etc/rc.conf
-- sysinstall generated deltas -- #Wed May 12 07:19:15 2010
#Created: Wed May 12 07:19:15 2010
#Enable network daemons for user convenience
#Please make all changes to this file, not to /etc/defaults/rc.conf
#This file now contains just the overrides from /etc/defaults/rc.conf
hostname="se-print"
ifconfig_vr0="192.168.4.9 netmask 255.255.255.0"
defaultrouter="192.168.4.1"
hald_enable="YES"
dbus_enable="YES"
saver="fire"
apache22_enable="YES"

/etc/resolv.conf
nameserver 216.199.0.132
nameserver 216.199.127.67

/etc/host
::1                          localhost localhost.my.domain
127.0.0.1                    localhost localhost.my.domain
192.168.4.9                  myhost myhost.my.domain
*I didn't put the rest of the file info here since it's all commented out anyway.

/etc/hosts/allow
ALL : ALL : allow
file "/etc/host.allow", 91 lines
*Everything else is commented out

/usr/local/etc/apache22
*Has nothing in it

I can't really think of anything else to add to this. Any help anyone can contribute I'd greatly appreciate it.
 
'http://localhost' or 'http://127.0.0.1' it gives me a 'Connection to Server Refused' error. "

-- most likely a permission problem. make sure you have o+x in the /usr/home/yourdir folder.

/usr/local/etc/apache22 should have the httpd.conf there, among other things.

mine has httpd.conf, and directories named: "Inlcudes, envvars.d, extra, magic, mime.types"
 
After going over everything twice and continuing to get the "Server Refused Connection" error I'm thinking it's something else. Would the default install of FreeBSD set the firewall to not allow connections? I haven't done anything with the firewall configuration so it didn't occur to me earlier but it seems like it might be a likely option. If this is a possibility what file would I need to change and what would I be looking for in the file? I've never messed around with Linux firewalls so I don't want to tweak something and make the situation worse. Thanks again for all the help.
 
You still haven't told anyone what's in /var/log/httpd-error.log. We don't even know if Apache is running at all. Run [cmd=]sockstat -l4p80[/cmd]. Also, why connect to localhost when you told Apache to be on 192.168.4.9? Try http://192.168.4.9/
 
DutchDaemon said:
Also, why connect to localhost when you told Apache to be on 192.168.4.9? Try http://192.168.4.9/
I tried that after the IP wouldn't work. Regardless of why or how, I did finally figure it out and it's now working.

I had the "Listen" line in the httpd.conf file commented out for some reason. It all seems to be working fine now. I appreciate everyone's input into this and I've definitely learned from it.
 
Back
Top