Setting up PHP

Setting up PHP

Posted by: almostvindiesel
Posted on: 2008-01-06 10:27:00

I'm new to web development and php.

I'm trying to setup a basic HelloWorld php script, and I'm having trouble with it.

1) If I try executing a hello world script with a .php extension, it works. If I try with .cgi execution, I get a 500 internal server error. I've configured dreamhost per the wiki (http://wiki.dreamhost.com/PHP#PHP_on_DreamHost and ), but still no luck.
2) Can i include php scripts in regular .html (or *.*html files)? Ideally, I'd like to create regular html files and add scripts wherever necessary.

Here's the source in the file:

<?php
echo "<html><body>Hello, world!</body></html>";
?>

Thanks!

~John



Re: Setting up PHP

Posted by: Atropos7
Posted on: 2008-01-06 10:47:00

In reply to:

1) If I try executing a hello world script with a .php extension, it works. If I try with .cgi execution, I get a 500 internal server error. I've configured dreamhost per the wiki (http://wiki.dreamhost.com/PHP#PHP_on_DreamHost and ), but still no luck.


You have to use a per-directory configuration file (.htaccess) to have either the web server execute .cgi files as PHP or re-write the URL.

In reply to:

2) Can i include php scripts in regular .html (or *.*html files)? Ideally, I'd like to create regular html files and add scripts wherever necessary.


Nope - DreamHost doesn't support mod_php anymore. Additionally it will slow performance if you have PHP parse every file whether or not it has PHP code in it.


cool openvein.org -//-

Re: Setting up PHP

Posted by: almostvindiesel
Posted on: 2008-01-06 10:59:00

Thanks Atropos7.

I created a .htaccess file in my cgi-bin directory with the following syntax:

<Directory /home/*/public_html/cgi-bin>
Options ExecCGI
SetHandler cgi-script
</Directory>

No luck. I also tried

Options ExecCGI

Still got a 500 server error. Any thoughts?

Tags: internal server error500 internal server errorworld scriptphp scriptsphp extensiondreamhosthtml fileshello worldexecution