Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have done the procedure below given in for installing PHP and Apache. When I start the Apache server, it is displaying "invalid command PHPIniDir". How can I fix this problem?

I wanted to learn PHP. When I started installing I came with this problem.

Editing Apache Conf File

Using Notepad open httpd.conf (should be start-menu shortcut "Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File"). Either at the very beginning or end of the file add the following lines: (NOTE: be sure to change BOTH C:/php parts to the directory you installed PHP to)

LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"
share|improve this question
Any reason why not on Linux OS? Will be much more easier. – Itay Moav May 27 '09 at 18:16
I have only windows xp – Warrior May 27 '09 at 18:17
Not a direct answer to your question, but have you considered installing an Apache distribution? I have found XAMPP to be very easy to set up and use: – Perspx May 27 '09 at 18:18
up vote 8 down vote accepted

I would recommend you using XAMPP. It is a complete package of Apache, PHP, MySQL and so on... You don't have to configure and you can easily stop the processes so that you don't have an open webserver running on your computer all the time which can be risky if accessible over the Internet.


share|improve this answer
what you don't like pain? – bobobobo Dec 16 '10 at 18:27
I tried upgrading xampp from 1.7.3 to 1.7.7 and everything broke. yay – Neil McGuigan Apr 14 '12 at 22:27

I vaguely remember having this problem as well. If I remember correctly you might need to add a trailing / to the PHPIniDir

PHPIniDir "C:/php/"
share|improve this answer

The only other alternative that I know of to XAMPP is to install WAMP. I've used WAMP many times but I haven't tried XAMPP. They are full LAMP stacks (well WAMP stacks) that contain Apache, MySQL and PHP.

share|improve this answer

As an alternative, drop the PHPIniDir command and place the php.ini in the same directory as the Apache.exe application.

share|improve this answer

I created a new file called php.conf. In that file I placed the following:


Loadfile "C:\php\php5ts.dll"

LoadModule php5_module "C:\php\php5apache2_2.dll"

PHPIniDir "C:\php"

AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps

Then I went to my httpd.conf file and included the php.conf file:


Include conf/extra/php.conf

I included the line above, right before these lines in my httpd.conf file, where all the other include lines are.

<IfModule ssl_module>
    SSLRandomSeed startup builtin
    SSLRandomSeed connect builtin
share|improve this answer

installation of both php and server,,, problems? Try this link on how to install php & apache web server through the use of xampp,, Here is a detailed instruction on how to install->

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.