Apache interview questions and answers

  1. On a fresh install, why does Apache have three config files - srm.conf, access.conf and httpd.conf? - The first two are remnants from the NCSA times, and generally you should be ok if you delete the first two, and stick with httpd.conf.
  2. What’s the command to stop Apache? - kill the specific process that httpd is running under, or killall httpd. If you have apachectl installed, use apachectl stop.
  3. What does apachectl graceful do? - It sends a SIGUSR1 for a restart, and starts the apache server if it’s not running.
  4. How do you check for the httpd.conf consistency and any errors in it? - apachectl configtest
  5. When I do ps -aux, why do I have one copy of httpd running as root and the rest as nouser? - You need to be a root to attach yourself to any Unix port below 1024, and we need 80.
  6. But I thought that running apache as a root is a security risk? - That one root process opens port 80, but never listens to it, so no user will actually enter the site with root rights. If you kill the root process, you will see the other kids disappear as well.
  7. Why do I get the message "… no listening sockets available, shutting down"? - In Apache 2 you need to have a listen directive. Just put Listen 80 in httpd.conf.
  8. How do you set up a virtual host in Apache?
    <VirtualHost www.techinterviews.com>
        ServerAdmin admin@techinterviews.com
        DocumentRoot /home/apache/share/htdocs/hostedsites
        ServerName www.techinterviews.com
        ErrorLog /home/apache/logs/error/hostedsites/error_log
        TransferLog /home/apache/logs/access/hostedsites/access_log
  9. What is ServerType directive? - It defines whether Apache should spawn itself as a child process (standalone) or keep everything in a single process (inetd). Keeping it inetd conserves resources. This is deprecated, however.
  10. What is mod_vhost_alias? - It allows hosting multiple sites on the same server via simpler configurations.
  11. What does htpasswd do? - It creates a new user in a specified group, and asks to specify a password for that user.
  12. If you specify both deny from all and allow from all, what will be the default action of Apache? - In case of ambiguity deny always takes precedence over allow.
This entry was posted in Unix/Linux, Web dev. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

7 Comments on Apache interview questions and answers

  1. Andrew
    Posted 11/16/2006 at 10:17 am | Permalink

    You would NOT want to do “killall httpd” on a Solaris machine. killall on solaris kills all processes, not just the ones matching a pattern. On Solaris, you’d be much better off with “pkill httpd”.

  2. Jasbir Singh
    Posted 7/11/2007 at 12:50 pm | Permalink

    You just stop the service with following command :

    service httpd stop

  3. Pushkar
    Posted 10/26/2007 at 8:39 am | Permalink

    Jasbir’s option is best.

    service httpd stop
    is the best choice to stop the httpd service.

  4. shah
    Posted 3/18/2008 at 12:47 pm | Permalink

    well, as for the htpasswd :

        1. the -c switch creates a user
        2. & just the htpasswd adds a new use the AuthGroup of the particular file..:)

  5. kunal
    Posted 4/15/2008 at 4:48 am | Permalink

    You can stop apache by issuing command
    apachectl stop or
    httpd -k stop

  6. Phoenix
    Posted 5/30/2008 at 12:43 am | Permalink

    The httpd.conf file consistency can also be checked with the command:
    httpd -t

  7. masana
    Posted 11/26/2008 at 5:19 am | Permalink

    2 cd /etc/init.d
    sh apache stop
    sh apache start

Post a Comment

Your email is never published nor shared. Required fields are marked *