# Handling files by http server



## mulligan81 (May 23, 2016)

As i understand when the server (e.g. Apache) receives a request it looks for file name extension to find associated mime-type. Then it looks for the handler handling this mine-type (i'm stating it based off adding PHP support to Apache). And here are my questions:


Is the above statement correct?
If so when there is no handler for given mime-type does it mean the default behavior - that is just send a file to the client?
If there is even no explicit extension - mime-type association defined (e.g. ._html_) the default action again is just send a file to the client?
According to some sources to add PHP support to Apache we have to use
_addType _directive: _AddType application/x-httpd-php .php_ while others say to use _addHandler_ directive: _AddHandler application/x-httpd-php .php_ which in my opinion is the only correct because _addType _should be used only for static documents. So why the _addType _version is still correct?
I found somewhere such a lines:


```
AddType text/html .php .phps 
AddHandler application/x-httpd-php .php 
AddHandler application/x-httpd-php-source .phps
```
Does it mean that _AddType _directive will be used if the server can't find the handler for _application/x-httpd-php_ mime-type and the action would be just to send .php source file to the client with _text/html_ mime-type in response?​


----------



## wmorri (May 29, 2008)

Hmm, it has been a long time since I have dealt with anything like this. First off, if you are just talking about PHP then have you installed PHP and have you looked to see if it is working? I would create a info.php file with the following.


```
<?php info(); ?>
```
If you are able to access this file then things sound be working for you. As for your first question, I do believe that your correct. As for the rest of your questions this isn't something i deal a lot with.


----------



## brent.charlebois (May 8, 2007)

You also need Apache Server that will 'execute' the PHP file. 

To make it all easier, I recommend you download WAMP Server. Here is a site which will download WAMP for you. 

http://wampserver.en.softonic.com/ 

WAMP is an acronym for Windows/Apache/MySQL/PHP. These 3 modules will be installed on your system. Download WAMP to the base directory (C;\) and it will create a folder named 'wamp' with all its folders. 

To execute PHP files, place those files in the wamp/www folder. To execute a file, enter in the address bar: localhost/phpfile.php with the actual name of the file. (do not enter www before the file name).

Try entering just localhost and see what displays.

Any Questions? I am here.


----------

