# PHP Problem



## aadryaan94 (Jun 28, 2013)

I install_ed_ PHP and Apache and MySQL and when I go to index.php, it do_es_n't open the web page, _it_ open_s_ the PHP script with codes.


----------



## Anonymous (Jun 28, 2013)

Add to /usr/local/etc/apache22/httpd.conf the following lines:


```
<IfModule php5_module>
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
</IfModule>
```

You might want to add index.php to the following directive:


```
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>
```

Finally, check that the php5_module is loaded:


```
...
LoadModule php5_module libexec/apache22/libphp5.so
...
```


----------



## aadryaan94 (Jun 28, 2013)

And ?

And?

`/usr/local/etc/rc.d/apache22 restart`

```
Performing sanity check on apache22 configuration:
httpd: Syntax error on line 106 of /usr/local/etc/apache22/httpd.conf: Cannot load /usr/local/libexec/apache22/libphp5.so into server: Cannot open "/usr/local/libexec/apache22/libphp5.so"
```


----------



## Anonymous (Jun 28, 2013)

How did you install which php?


----------



## aadryaan94 (Jun 28, 2013)

I install_ed_ *PHP*. But _it_ do_es_n't work! Probably not installed very well.


----------



## ShelLuser (Jun 28, 2013)

aadryaan94 said:
			
		

> I install_ed_ PHP and Apache and MySQL and when I go to index.php, it do_es_n't open the web page, _it_ open_s_ the PHP script with codes.


Actually this doesn't tell us much. Which version of FreeBSD, which version of PHP and which version of Apache? Knowing that would help some.

My guess though is that you forgot to enable support for Apache when you installed PHP. The common PHP port (lang/php5) has an option Apache which is disabled by default. If you don't enable it then it also won't build mod_php5.so which is what you need to enable PHP support.

Also; normally you don't need to modify httpd.conf to enable PHP. That's because PHP will add a file called php_settings.conf in Apache's Includes directory. And all the *.conf files in that directory are normally automatically loaded when you start Apache (at the end of a default httpd.conf file you can normally find an Include statement which does this).


----------



## mcochris (Jul 5, 2013)

Did you include the starting php tag in your index.php file?  E.g.

```
<?php
phpinfo();
```


----------



## throAU (Jul 5, 2013)

As above, assuming your PHP script is actually correct, it very much sounds like you haven't told Apache that .php files should be treated as PHP scripts via the Mime-Type definition, or the PHP module is missing.


----------



## SirDice (Jul 5, 2013)

aadryaan94 said:
			
		

> And?
> 
> `/usr/local/etc/rc.d/apache22 restart`
> 
> ...



Did you install lang/php5 from a package? That doesn't contain the Apache module. You have to build the port to get it.


----------

