Monday 24 December 2012

SRE Interview Questions: Apache

  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 does apachectl graceful do? It sends a SIGUSR1 for a restart, and starts the apache server if it’s not running.
  3. 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.
  4. 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.
  5. 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.
  6. What does htpasswd do? It creates a new user in a specified group, and asks to specify a password for that user.
  7. 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.
  8. How do you check for the httpd.conf consistency and any errors in it? apachectl configtest
  9. 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.

NOTES:

*)
 If you need to use one of those non-loaded modules, look in the httpd.conf file to see all the available modules. Each of the available modules has a corresponding LoadModule line. To show you an example, the LoadModule section begins with these seven lines:

#LoadModule mmap_static_module modules/mod_mmap_static.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule env_module         modules/mod_env.so
LoadModule config_log_module  modules/mod_log_config.so
LoadModule agent_log_module   modules/mod_log_agent.so
LoadModule referer_log_module modules/mod_log_referer.so
#LoadModule mime_magic_module  modules/mod_mime_magic.so


*)
For Apache to use a dynamically shared module, that module must have a LoadModule line and an AddModule  line in httpd.conf.

LoadModule foo_module     modules/mod_foo.so
AddModule mod_foo.c


./configure [userflags] --with-eapi-only

To configure apache for additional modules you need to add LoadModule directive in httpd.conf or modules.conf file


Please note that your Apache server must configure for Dynamic Shared Objects (DSOs). Let us assume you have downloaded the module called mymodule.c and you would like to compile and use this module, then you can use Apache apxs utility to compile and install this module:

Build and install a third-party Apache module, say mod_foo.c, into its own DSO mod_foo.so outside of the Apache source tree using apxs:

# apxs -c mymodule.c
# apxs -i -a -n mymodule mymodule.la

LoadModule mymodule /usr/lib/httpd/modules/mymodule.so


No comments:

Post a Comment