Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > Mac Systems > Re: Getting emb...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 6 Topic 24329 of 24953
Post > Topic >>

Re: Getting embedded PHP to work with Apache on OSX

by Marko Vihoma <marko@[EMAIL PROTECTED] > Jul 4, 2008 at 08:56 AM

Hamad bin Turki al Salami wrote:
> I enabled apache web server and php on an OSX leopard server
> by:
> enabling Web Sharing in Preferences
> uncommenting
> LoadModule php5_module  ...
> in httpd.conf
> 
> I also created a php.ini file.
> 
> When I serve a file with .php extension, everything works fine. However,
> if I serve an .html file with embedded php tags, the tags aren't
> executed. For instance, serving a page with:
> 
> <html>
>  <head>
>   <title>PHP Test</title>
>  </head>
>  <body>
>  <?php phpinfo(); ?>
>  </body>
> </html>
> 
> 
> 
> gives a blank page.
> 
> 
> Is there something else I need to do to get embedded php tags to work?
> 

I don't know if it's too good an idea to force .html files to be
processed through mod_php, but here's how to do it. You have
/etc/httpd/httpd.conf, where you have a block like below:

-- BEGIN original /etc/httpd/httpd.conf --

<IfModule mod_php4.c>
    # If php is turned on, we repsect .php and .phps files.
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    # Since most users will want index.php to work we
    # also automatically enable index.php
    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

-- END original /etc/httpd/httpd.conf --

Modify that block to include an AddType declaration for .html:

-- BEGIN new /etc/httpd/httpd.conf --

<IfModule mod_php4.c>
    # If php is turned on, we repsect .php and .phps files.
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php .html
    AddType application/x-httpd-php-source .phps

    # Since most users will want index.php to work we
    # also automatically enable index.php
    <IfModule mod_dir.c>
        DirectoryIndex index.html index.php
    </IfModule>
</IfModule>

-- END new /etc/httpd/httpd.conf --

HTH :)

-- 
"If I can't smoke and swear I'm ****ed."

marko [dot] vihoma [at] pp1 [dot] inet [dot] fi
 




 6 Posts in Topic:
Getting embedded PHP to work with Apache on OSX
Hamad bin Turki al Salami  2008-07-03 18:28:32 
Re: Getting embedded PHP to work with Apache on OSX
Tom Stiller <tomstille  2008-07-04 02:24:14 
Re: Getting embedded PHP to work with Apache on OSX
Hamad bin Turki al Salami  2008-07-04 11:35:40 
Re: Getting embedded PHP to work with Apache on OSX
Michael Vilain <vilain  2008-07-04 01:29:43 
Re: Getting embedded PHP to work with Apache on OSX
Marko Vihoma <marko@[E  2008-07-04 08:56:18 
Re: Getting embedded PHP to work with Apache on OSX
Sander Tekelenburg <us  2008-07-04 20:40:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 17:15:51 CDT 2008.