Ubuntu – Can’t get Apache2 working

apache-2.2httpdUbuntuubuntu-10.04

I had installed Apache2 before, and now when I tried running it again, it doesn't.
My Apache2 settings are:

jatin@jatin-ubuntu:/var/run$ apache2 -V
Server version: Apache/2.2.14 (Ubuntu)
Server built:   Nov 18 2010 21:17:19
Server's Module Magic Number: 20051115:23
Server loaded:  APR 1.3.8, APR-Util 1.3.9
Compiled using: APR 1.3.8, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT=""
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/apache2.conf"

When I do this, the following errors come up:

jatin@jatin-ubuntu:/var/run$ httpd status
No command 'httpd' found, did you mean:
 Command 'dhttpd' from package 'dhttpd' (universe)
 Command 'xttpd' from package 'xtide' (universe)
 Command 'thttpd' from package 'thttpd' (universe)
httpd: command not found

My /etc/apache2/ports.conf looks like:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

#NameVirtualHost *:80
Listen 80

#<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
#    Listen 443
#</IfModule>

#<IfModule mod_gnutls.c>
#    Listen 443
#</IfModule>

My sites-available directory has these two files:

jatin@jatin-ubuntu:/etc/apache2$ cd sites-available/
jatin@jatin-ubuntu:/etc/apache2/sites-available$ ls
default  default-ssl

When I look into sites-enabled directory, it has nothing:

jatin@jatin-ubuntu:/etc/apache2/sites-available$ cd ../sites-enabled/
jatin@jatin-ubuntu:/etc/apache2/sites-enabled$ ls

My /var/log/apache2/error.log file shows this:

[Sat Mar 26 17:54:08 2011] [error] [client 127.0.0.1] File does not exist: /htdocs
[Sat Mar 26 17:54:15 2011] [error] [client 127.0.0.1] File does not exist: /htdocs
[Sat Mar 26 17:54:23 2011] [notice] caught SIGTERM, shutting down
[Sat Mar 26 17:54:26 2011] [notice] Apache/2.2.14 (Ubuntu) DAV/2 SVN/1.6.6 configured -- resuming normal operations

I read on Web that this has got to do something with the Server root not properly set and therefore it looks for the /htdocs folder.

QUESTIONS:

  1. Why does the httpd status doesn't show anything??
  2. Is everything in my ports.conf file correct?? I have just one line uncommented for the Listen.
  3. Aren't there supposed to be sym links for the default in the sites-enabled directory???
  4. When I do sudo /etc/init.d/apache2 restart/stop/start everything works fine, but nothing shows up when I open http://localhost/ or http://localhost:80/ or http://localhost:8080/???
  5. What is this thing with Server Root and have i set it correct??

Best Answer

  • Why does the httpd status doesn't show anything?

Because you do not have httpd installed. Perhaps you meant /etc/init.d/httpd status? The equivalent command on an Ubuntu system is /etc/init.d/apache2 status.

  • Is everything in my ports.conf file correct?

If you are only going to run one site then it should be ok. If you want to have more sites running as virtualhosts you will need to uncomment the NameVirtualHost line too.

  • Aren't there supposed to be sym links for the default in the sites-enabled directory?

They are created when you use the a2ensite command to enable a site e.g.

a2ensite default

will enable the default website by creating the link.

  • When I do sudo /etc/init.d/apache2 restart/stop/start everything works fine...

Looking at the error messages in your question, they would indicate that you are not seeing nothing. You will be seeing a 404 Not Found error message. This is caused because you do not have any sites enabled.

  • What is this thing with Server Root and have I set it correct

I suspect that you mean DocumentRoot, if there is no DocumentRoot configured then Apache defaults to /htdocs. Enable a site using the command above and see what happens. You should get a message saying something like "It Works ..."