How to setup httpd.conf file. [ Especially to configure with php for postgres admin ] The /usr/apache2 is the latest 2.2 version. The /usr/apache is old version. The "httpd -l" command lists the core static modules : Compiled in modules: core.c prefork.c http_core.c mod_so.c The core directives are recognized by these core modules. Additional modules can be loaded. For more info see: http://httpd.apache.org/docs/2.0/mod/core.html Module Name Supported Directives core Core directives like ServerRoot, Listen etc. mod_so , LoadModule etc mod_mime TypesConfig Also, take a note of support for .htaccess file. Following Variables are important: # The path where binaries live. Leave this as it is. ServerRoot "/usr/apache2/2.2" # Allows you to listen to specific IP/port. #Listen 12.34.56.78:80 # # Multiple Listen statements are supported. Later they can be # assigned to different virtual hosts. # Also you can assign separate "Listen 443" to later assign # this to SSL virtual host. # To do this you will do ... SSLEngine On ... # Listen 80 # # Can define additional variables by: httpd -Dmy64bit -f httpd.conf # Include /etc/apache2/2.2/conf.d/modules-64.load Include /etc/apache2/2.2/conf.d/modules-32.load # This modules-64.load contains entries like: # LoadModule authn_anon_module libexec/amd64/mod_authn_anon.so # libexec/amd64/ contains modules like: # auth*, cgid, mime, perl, php5, proxy, ssl, vhost_alias etc. # # Note: Though php5, perl, virtualhost modules are present, they are not # loaded by default from modules-64/32.load !!! # # Note: Now all basic modules are already loaded. # Now continue with config depending on modules loaded ... # # If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch. # # User/Group: The name (or #number) of the user/group to run httpd as. # It is usually good practice to create a dedicated user and group for # running httpd, as with most system services. # # Note: mask this out to run httpd with your uid and group by default # User webservd Group webservd # Main server configuration follows # ServerAdmin just appears on error document etc. ServerAdmin you@yourhost.com # Server uses ServerName to identify itself. Use IP if no DNS present ServerName 127.0.0.1 # Your starting point directory where index.html lives. DocumentRoot "/var/apache2/2.2/htdocs" # # Disallow access from root dir / then allow access to selected dir. # For this use directive which is core. # # ie. Enclose a group of directives that apply only to the named # file-system directory and sub-directories # Options FollowSymLinks AllowOverride None Order deny,allow Deny from all # # example: # Regular expressions allowed (with ~). The * does not match "/" # so you can use * to match with "any file" # # Note: by default apache allows all: Allow from all # Options Directive Description: Configures what features are available in a particular directory Syntax: Options [+|-]option [[+|-]option] ... Default: Options All Context: server config, virtual host, directory, .htaccess Override: Options Status: Core Module: core Option can be set as: All All options except for MultiViews. This is the default setting. None: No extra features enabled. ExecCGI : cgi scripts allowed Indexes : Allow auto directory listing E.g. Options +Includes -Indexes ; Allows includes and denies directory listing. -------------------------------------------------------------- Allow Directive: Description: Controls which hosts can access an area of the server Syntax: Allow from all|host|env=env-variable [host|env=env-variable] ... E.g. Allow from .net example.edu Allow from 10.1.0.0/16 SetEnvIf User-Agent ^KnockKnock/2\.0 let_me_in Order Deny,Allow Deny from all Allow from env=let_me_in -------------------------------------------------------------- Order Directive Description: Controls the order of evaluation for access. -------------------------------------------------------------- Require user david -------------------------------------------------------------- Satisfy Directive Require valid-user Order allow,deny Allow from 192.168.1.1 Satisfy Any Above directive will allow any valid user OR anybody from 192.168.1.1 host. -------------------------------------------------------------- AllowOverride Directive Description: Types of directives that are allowed in .htaccess files Only available in Directory section E.g. AllowOverride All|None|directive-type [directive-type] ... AllowOverride All|None|AuthConfig|FileInfo|Indexes|Limit|Options If "None" is specified, the .htaccess file is ignored. -------------------------------------------------------------- # Put your own error log path here ... ErrorLog /var/apache2/2.2/logs/error_log .... # put your path here... CustomLog /var/apache2/2.2/logs/access_log common ... # if most of the time you are dealing with text data, specify this: DefaultType text/plain TypesConfig /etc/apache2/2.2/mime.types # You need to add something here to enable PHP. # The typical entries in mime.types file: # application/pdf pdf # application/activemessage # If the file extension is not specified, the file header will be read # to guess the mime type and will be recognized and sent to the # browser accordingly. The browser can choose what application to # activate to read this mime data. # # # # # # Load module specific configs here. # E.g. ssl.conf specifies parameters used for ssl module. # Keep ssl module disabled here and include only php5.conf # #Include /etc/apache2/2.2/conf.d/*.conf Include /etc/apache2/2.2/conf.d/php5.conf # Note: php5 module is supported only with 32bit httpd!!! # This php5.conf loads mod_php5.so and specifies mime type # for php and specifies "DirectoryIndex index.php" ============================================================================== Following is the diff between /etc/apache2/2.2/httpd.conf and /home/thava/apache/httpd.conf : 30a31,33 > PidFile /home/thava/apache/logs/httpd.pid > LockFile /home/thava/apache/logs/accept.lock > 40c43 < Listen 80 --- > Listen 7080 50a54,57 > # > #Include /etc/apache2/2.2/conf.d/php5.conf > # > 52c59 < Include /etc/apache2/2.2/conf.d/modules-64.load --- > Include /home/thava/apache/conf.d/modules-64.load 55c62 < Include /etc/apache2/2.2/conf.d/modules-32.load --- > Include /home/thava/apache/conf.d/modules-32.load 68,69c75,76 < User webservd < Group webservd --- > User thava > Group staff 105c112 < DocumentRoot "/var/apache2/2.2/htdocs" --- > DocumentRoot "/home/thava/apache/docs" 132c139 < --- > 167c174 < DirectoryIndex index.html --- > DirectoryIndex index.html index.php 187c194 < ErrorLog /var/apache2/2.2/logs/error_log --- > ErrorLog /home/thava/apache/logs/error_log 216c223 < CustomLog /var/apache2/2.2/logs/access_log common --- > CustomLog /home/thava/apache/logs/access_log common 252c259 < ScriptAlias /cgi-bin/ "/var/apache2/2.2/cgi-bin/" --- > ScriptAlias /cgi-bin/ "/home/thava/apache/cgi-bin/" 261c268 < #Scriptsock /var/run/apache2/2.2/cgisock --- > Scriptsock /home/thava/apache/run/cgisock 268c275 < --- > 292a300,301 > AddType application/x-httpd-php .php > 370c379,380 < Include /etc/apache2/2.2/conf.d/*.conf --- > #Include /etc/apache2/2.2/conf.d/*.conf > Include /home/thava/apache/conf.d/*.conf Use this function to convert httpd.conf system template to yours: newhttpdconf(){ srcfile=$1 MYDOCROOT=/home/thava/apache/mydocs MYLOGDIR=/home/thava/apache/logs MYLISTENPORT=8090 cat $1 | sed -e ' # By default, httpd creates pid, lock files in /var/run/* # Change this since you are not root and you have no permission # Include these directives after ServerRoot directive. /^ServerRoot.*/ { a\ PidFile /home/thava/apache/logs/httpd.pid\ LockFile /home/thava/apache/logs/accept.lock } # Change default listen port s/^Listen[ \t].*/Listen '"$MYLISTENPORT"'/ # Mask the User, Group directives. Allow it to run under default user/group s/^User[ \t].*/#&/ s/^Group[ \t].*/#&/ # Replace the DocumentRoot and logs dir path s;/var/apache2/2.2/htdocs;'"$MYDOCROOT"'; s;/var/apache2/2.2/logs;'"$MYLOGDIR"'; # Include only php5.conf and not ssl.conf s;^Include [ \t]*/etc/apache2/2.2/conf.d/\*.conf.*;Include /etc/apache2/2.2/conf.d/php5.conf; ' }