# Apache22 php5 What am I doing wrong?



## jchutch2 (Jan 26, 2010)

I have recently upgraded to FreeBSD 8. I am trying to get PHP5 to work with my Apache22. I can execute the php script from the command line IE 
	
	



```
#php test.php
```
 and it executes correctly. I attempt to run it from a browser, any browser, and it attempts to download the file instead of execute it.

I have the following PHP related lines in my httpd.conf:


```
LoadModule php5_module        libexec/apache22/libphp5.so
    <IfModule mod_php3.c>
        <IfModule mod_php5.c>
            DirectoryIndex index.php index.php3 index.html
        <IfModule !mod_php4.c>
            DirectoryIndex index.php3 index.html
    <IfModule !mod_php3.c>
        <IfModule mod_php5.c>
            DirectoryIndex index.php index.html index.htm
        <IfModule !mod_php4.c>
    DirectoryIndex index.php index.html index.htm
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps
```

Any thoughts on why it's not working?

Thanks!


----------



## SirDice (Jan 26, 2010)

Did you use the package or the port to install php?

By default the apache module isn't build. That means it's not in the package. So you have to build from the port.


----------



## jchutch2 (Jan 26, 2010)

SirDice said:
			
		

> Did you use the package or the port to install php?
> 
> By default the apache module isn't build. That means it's not in the package. So you have to build from the port.



I have triple verified that php 5.2.12 was installed with the "build apache module" selected. []


----------



## nychold (Jan 26, 2010)

This may be a stupid question, and if it is, I apologize, but do you close your [font="Courier New"]IfModule[/font]s?


```
LoadModule php5_module        libexec/apache22/libphp5.so
    <IfModule mod_php3.c>
        <IfModule mod_php5.c>
            DirectoryIndex index.php index.php3 index.html
        </IfModule>
        <IfModule !mod_php4.c>
            DirectoryIndex index.php3 index.html
        </IfModule>
    </IfModule>
    <IfModule !mod_php3.c>
        <IfModule mod_php5.c>
            DirectoryIndex index.php index.html index.htm
        </IfModule>
        <IfModule !mod_php4.c>
        </IfModule>
    </IfModule>
    DirectoryIndex index.php index.html index.htm
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps
```


----------



## jchutch2 (Jan 26, 2010)

Yes. All IfModules are closed.


----------



## roddierod (Jan 26, 2010)

Anything in the apache error files?

Set up your PHP.ini to write an error file. Restart Apache and see if that logs anything.


----------



## jchutch2 (Jan 26, 2010)

This is the only error:
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/20060613-debug/session.so' - Cannot open "/usr/local/lib/php/20060613-debug/session.so" in Unknown on line 0


----------



## roddierod (Jan 26, 2010)

Well the only other thing the comes to mind is maybe in your PHP.ini you have


```
short_open_tag = Off
```

But you php files start with

```
<?
```

instead of 
	
	



```
<?php
```

which would cause the file to try and download or just display depending on the browser settings.


----------



## jchutch2 (Jan 26, 2010)

Weird. I had the test.php in the root directory of my website and it didn't work. I put it in a subdirectory and it works. In the httpd.conf, I have /usr/local/www/website/* and not just the top level directory, I guess. Well, thanks for looking for me guys! I do appreciate it!


----------



## anti (Jan 31, 2010)

i faced same problem before!!


----------

