PHP Problem

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

Code:
<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:

Code:
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

Finally, check that the php5_module is loaded:

Code:
...
LoadModule php5_module libexec/apache22/libphp5.so
...
 
And ?

And?

/usr/local/etc/rc.d/apache22 restart
Code:
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"
 
aadryaan94 said:
I installed PHP and Apache and MySQL and when I go to index.php, it doesn't open the web page, it opens 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).
 
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.
 
aadryaan94 said:
And?

/usr/local/etc/rc.d/apache22 restart
Code:
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"

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