Tuesday, January 25, 2011

PHP doesn’t run through Snow Leopard Web Sharing

I've followed all the tutorials and uncommented the relevant lines in httpd.conf, but PHP files do not render under Web Sharing.

The server just serves up the source code instead of running it.

I know that PHP works, because I can run it straight from the Terminal using the "php" command.

What is happening here?

  • To clarify:

    1) You're using the installation of Apache provided by Apple in Mac OS X? Which version of Mac OS X? (10.x, Server or Client?)

    Mac OS X 10.4 only provides Apache 1.3, 10.6 only provides 2.0

    In Mac OS X 10.5 Apple provides both Apache 1.3 and Apache 2.0 and by default Apache 2.0 is used. Apache 1.3's configuration files are at /etc/httpd/ while Apache 2.0's are in /etc/apache2/

    2) The commands you're following are restarting the right version of Apache?

    If Mac OS X 10.5 to restart 1.3 you need to use apachectl-1.3 instead of apachectl for 2.0.

    From Chealion
  • you need to edit the httpd.conf in /etc/apache2/

    sudo vim /etc/apache2/httpd.conf

    go to line 116 and uncomment the line...

    LoadModule php5_module libexec/apache2/libphp5.so

    also double check that you have an /etc/apache2/other/php5.conf

    if not, make one and put the following

     <IfModule php5_module>
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
    
        <IfModule dir_module>
                DirectoryIndex index.html index.php
        </IfModule>
     </IfModule>
    

0 comments:

Post a Comment