Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between httpd.conf, php.ini and .htaccess

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?

like image 919
SexyBeast Avatar asked Sep 07 '12 21:09

SexyBeast


2 Answers

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.

like image 97
Robert Avatar answered Sep 18 '22 02:09

Robert


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.
like image 33
Xeoncross Avatar answered Sep 20 '22 02:09

Xeoncross