Sample Apache Setup for Windows

Derek Jones edited this page Jul 5, 2012 · 14 revisions
Clone this wiki locally

Category:Help Category:Help::ApacheConfig

My development setup

This is how I've setup up my testing suite of Apache, MySQL and PHP (and yes, I don't like prefabricated bundles with a lot of third party scripts/plugins/apps included). I must stress that this is not something that you would put on a production server! You should also consider this as a stub, not a full blow fool-proof setup walk through - but you should get some hints here.

This document assumes a couple of things, like paths etc. Installation directories: d:\dev\apache d:\dev\mysql d:\dev\php

Development directories: (Since I use more than PHP I have it sorted this way) d:\www\php* <- this is where you'd store your CI apps d:\www...

Download and Install

First I downloaded Apache, MySQL (you want the lighter Essentials package) and PHP.

There's alot of options that you can make to lower the resources used by the install, but I won't venture into that - there's book about it, thick books...

The nice trick with my setup is that by using vhosts (virtual hosts) I have an easily accessible setup for my different projects (not necessarily related to CI), right now I have these cool urls;


These are made by the usage of Apache's vhosts and the windows hosts (C:\WINDOWS\system32\drivers\etc\hosts) file you can make nice URL's, but that's not the point - really, it makes it alot easier to separate projects and expand/incorporate them.

To make a new "host", you first add it to the hosts file like this

then you add it to the Apache vhost configuration file (httpd-vhosts.conf), like this.

<VirtualHost *:80>
  DocumentRoot d:/www/php/
  ErrorLog logs/mynew-error_log

another then... reload apache and you're set to use Code Igniter projects.

This may not make alot of sense on why to use a setup like this, but when you have 10-15 projects/forks/tests running on your can it makes life easier...

Below are my configuration settings... I hope this is of use :-)

My httpd.conf

#----- Base Setup -----------------------------------------------------------
ServerRoot "d:/dev/apache"
Listen *:80

ThreadsPerChild 50
MaxRequestsPerChild  0

ServerAdmin admin@stardust
ServerName stardust
DocumentRoot "D:/www/php"

EnableSendfile Off
EnableMMAP Off

#----- Module Loading -------------------------------------------------------
LoadModule authn_default_module modules/
LoadModule authz_host_module modules/
LoadModule dir_module modules/
LoadModule mime_module modules/
LoadModule rewrite_module modules/
LoadModule setenvif_module modules/
LoadModule php5_module d:/dev/php/php5apache2.dll

#----- Root Directory -------------------------------------------------------
<Directory />
    Options Indexes FollowSymLinks
    AllowOverride ALL
    Order allow,deny
    Allow from all

<IfModule dir_module>
    DirectoryIndex index.php  dispatch.fcgi index.html

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all

#----- Logging Configuration ------------------------------------------------
ErrorLog logs/error.log
LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    CustomLog logs/access.log common

#----- Module Configurations ------------------------------------------------
DefaultType text/plain
<IfModule mime_module>
  TypesConfig conf/mime.types
  AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
  AddType application/x-httpd-php .php
    AddType application/x-httpd-phps .phps

<IfModule php5>
    PHPIniDir "d:/dev/php"

<IfModule cgid>
    AddHandler fastcgi-script .fcgi

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "D:/dev/Apache/cgi-bin/"

#----- Extra Configurations -------------------------------------------------
Include conf/extra/httpd-vhosts.conf

My httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
  nServerName stardust
  DocumentRoot d:/www/php
  ErrorLog logs/stardust-error_log

<VirtualHost *:80>
    ServerName blog.stardust
    DocumentRoot d:/www/php/blog
    ErrorLog logs/blog.stardust-error_log

My hosts file       stardust    blog.stardust       localhost

My php.ini

This is the two things I've altered.

doc_root = "c:\dev\www"
extension_dir = "d:\dev\php\ext"