Take the 2-minute tour ×

I am about to start learning Apache. All resources I am looking into, mention either php.ini, or .htaccess or httpd.conf files for setting configurations and stuff. But none of them are clear on the difference between these 3 files. Can anyone explain the difference and their usage?

share|improve this question
httpd.conf is global settings for apache. .htaccess can be applied per folder.. php.ini is a separate animal entirely - configuration for php –  ethrbunny Sep 7 '12 at 21:31
I read something like that. What do you mean by per folder? –  Cupidvogel Sep 7 '12 at 21:33
htaccess files can be used to apply apache configurations on a folder by folder basis (instead of globally - via httpd.conf). –  ethrbunny Sep 7 '12 at 21:34
Yes, what is meant by folder here? Is it that if there are 10 HTML files in a 3-level deep folder structure, with a htaccess file for each folder, each htaccess file's directives will apply to the HTML/PHP files within that folder only? –  Cupidvogel Sep 7 '12 at 21:36
yes - each htaccess applies to the folder its in. there might be some directives that apply to sub-folders but i haven't seen them. –  ethrbunny Sep 7 '12 at 21:44

3 Answers 3

up vote 4 down vote accepted

httpd.conf (it can actually be named differently on some platforms, but that's the default) is the master configuration file for Apache. You can use Include statements to pull in external configuration files. httpd.conf is read in when Apache starts or if you run a 'reload'.

.htaccss is a per-directory configuration file for Apache. You can enable or disable the use of .htaccess files in your httpd.conf file. Where possible its been recommended to me to turn .htaccess use off, as Apache will check the file every time a request causes it to read the directory.

PHP is, as you probably know, separate from Apache, although often used with it. php.ini is the configuration file for the PHP engine.

share|improve this answer
What is meant by directory or folder here? –  Cupidvogel Sep 7 '12 at 21:34

Every daemon or application has it's own configuration files. On linux these are often located in the /etc directory. You will have to learn to edit each one according to the program. the /etc/php5/php.ini is different from the /etc/apache2/httpd.conf and so on.

Think of them like different types of files. a Word document is not the same as a JPEG Image or a AVI video.

  • The PHP.ini controls PHP's settings
  • The .htaccess controls apache settings for a given folder (and all child folders)
  • The httpd.conf controls apache's settings.
share|improve this answer
  • php.ini is a configuration file where you specify options for things related specifically to php, for instance CURL
  • .htaccess is where you specify options for URI routing and folders options on your server
  • httpd.conf is a configuration file where you specify options for things related specifically to apache
share|improve this answer

Your Answer


