PDA

View Full Version : #!/usr/local/bin/php


tcjay
11-29-01, 01:02 PM
I have the phrase #!/usr/local/bin/php print at the top of each page on the discussion board. This is the line they had me place at the top of the files that are directly executable. The problem is I don't know which file is generating this line.

Does anyone have any ideas?

Thanks :)

firebolt
12-5-01, 11:30 PM
Hi tcjay,

I had the same issue when I included the:
#!/usr/local/bin/php
at the top of every source file I used in my discussion board. What you need to realize is php can include other php files, so that they will not need to have the #!.. at the top of them. Only the ones that are actually gone to when a user views your board need to have that heading.

Hope that helps,
Garett

wwuud
12-6-01, 04:58 PM
I have never needed the #!/usr/local/bin/php line at the top of any of my php scripts. Just name the file with a .php extension & the interpreter will run the scripts.

It may be that the .htaccess file (or other server control file) is required to direct the server to hand the file off to the php interpreter. I don't remember what's in my .htaccess

Paece,
- Earl

tcjay
12-6-01, 05:21 PM
Tfiles directly executed using php will not function if that line ######## is not included. I would be glad to try something else to see if it works. Are you with POWWEB and hwat discussion board do use?

wwuud
12-6-01, 06:13 PM
I uploaded the following file (3 lines total) to my site at http://wwuud.net/test.php

<?php
echo "Hello world! <br>\n";
?>

It works as intended.

My site is on saturn.powweb.com

I have phpBB running (with NO #! lines) and have run CyBoards on a PowWeb site.

Stormwolves
12-6-01, 06:28 PM
Could you please post your .htaccess file here? I would be very interested in getting my php scripts to work w/o the need for the #! directives....

or to have my site moved over to saturn :)

Thanks

shanff
12-6-01, 09:09 PM
the first line directive is used when the system that you are executing the script on does not know where the interpreter is. Much like needing to specify c:\windows\command\edit.com when the path of a dos/windows based system is not set. if .php on the server is associated with /usr/local/bin/php, then you shouldn't need the first line directive assuming the file is set as an executable script via permissions

Stormwolves
12-7-01, 02:04 PM
I am no whiz with apache... could one please post such a .htaccess file here that would make the #! syntax obsolete? :)

shanff
12-7-01, 06:34 PM
an .htaccess file will not make the #! notation obsolete. .htaccess is for web based user authentication, #! is used to let a script know where the script interpreter is located on the server.

Stormwolves
12-7-01, 07:10 PM
I was able to come up with a .htaccess that changed the .php ending to directly go to the php CGI... but the problem is that the path to the .php file will get messed up if you do that... and I wasn't able to change that, yet...

.htaccess can do A LOT more than just user authentication, Shanff ;)

tcjay
12-7-01, 09:07 PM
If I used CGI instead of PHP would that resolve the problem? :confused:

shanff
12-7-01, 09:54 PM
if you're saying that having the #! is a problem, no, cgi won't make any difference, you still need a #!/usr/local/bin/perl or whatever the path to perl is. unix does not automatically know what program is used to parse a specific script. Windows knows how to because it associates file extensions with a particular program (.cgi is run by perl.exe and php is run by php.exe, etc..) in unix, you don't have to have file extensions, it doesn't work that way. for this reason you need the #! notation. it tells the server how to parse the file. there is no problem, it's how unix works by design.

tcjay, if what you mean is that when you view the pages, the #! is printing out on the top of each page, you probably put the #! stuff into an .html file (or all of the files). only the .cgi and .php files need this line

tcjay
12-8-01, 02:20 PM
Thanks for the pointers.

petergehrig
12-19-01, 01:04 AM
I saved the following 5 lines as test.php:

#!/usr/local/bin/php
<html><head><title>PHP Test</title></head>
<body>
<?php echo "Hello World<p>"; ?>
</body></html>

Then I put test.php into my htdocs directory.
Then I set test.php to chrmod 755.
Then I tried to view it at http://www.freedone.com/test.php
Then I got a 500 Internal Server Error.

Question: What did I wrong???

Thanks a lot!

Peter

tcjay
12-19-01, 01:28 AM
Does the folder also have the right permission 755?

petergehrig
12-19-01, 01:38 AM
No it had chmod 777. Now it's set to 755 - and it works! Thanks a lot!