cancel
Showing results for 
Search instead for 
Did you mean: 

Where to store PHP scripts

N/A

Where to store PHP scripts

Hi,

Can any of you experienced PHP scripters let me know where I should store my PHP scripts ?

The problem is, if I store them in a directory within cgi-bin, the scripts cannot be accessed (browser error says "You don't have permission to access /cgi-bin/php/...") I've set the appropriate permissions (i think).
If I store the PHP scripts in a higher level directory, they can be accessed directly by anyone who types in http://cgi.username.force9.co.uk/php/ !!

Any solutions fellow PHPers ??

Thanks, Neil.
4 REPLIES
Sword
Grafter
Posts: 41
Registered: 10-10-2007

RE: Where to store PHP scripts

Neil, I'm not that experienced but your scripts need to go in the root folder (the one you see immediately after FTP'ing in), not within the cgi-bin.

If you don't want unauthorised use then use .htaccess for security (see the excellent www.sheamus.f9.co.uk for more info if necessary)

Hope this helps,
Sword
N/A

RE: Where to store PHP scripts

> Neil, I'm not that experienced but your scripts need to go in the root folder (the one you see immediately after FTP'ing in), not within the cgi-bin.
>
> If you don't want unauthorised use then use .htaccess for security (see the excellent www.sheamus.f9.co.uk for more info if necessary)
>
> Hope this helps,
> Sword

Neil, your original location for your files was fine, they do not need to be in your root - actually that's not a terribly clever place to put them.

Placing them within a categorised directory structure beneath cgi-bin is fine.

You probably have incorrect permissions set - you want to chmod 755 your script file PLUS you need to have execute permissions on your directory too - so if your script is in the following path

cgi-bin/php/myscript.php

you need to:

chmod 755 cgi-bin/php/myscript.php
chmod 755 cgi-bin/php

I assume that cgi-bin has the correct permissions already - you'll only have to set your directory execute permissions once.

Have you been using WS-FTP by any chance? If so dont fall into the trap of thinking that the CHMOD (UNIX) menu option displays the current permissions on the file - it displayes the LAST setting you used (at least it does at version 5.06) - its understandable when you think of how it is being done but a bit of a trap for unwary - particularly for windows users.

There is another possible source of your problem that I have experienced before - if you ae using Internet Explorer and get a 403 No permission error and then reset the permissions correctly using say chmod - when you refresh the explorer view it doesnt always pick up the change correctly - even when you force a hard refresh. I have on occasion had to quit explorer and restart to get it to pick of the script correctly again.

Hope this is of some help.


N/A

RE: Where to store PHP scripts

Thank you both for your advice, it's much appreciated. How did you guess I was using WS-FTP ? What's more, how did you know it was version 5.06 ? Very clever !!

And to think, i've been using WS-FTP just to check file permissions on occasion ! Silly Sod !

Anyway, i'll let you know how I get on.

Cheers, Neil.
Sword
Grafter
Posts: 41
Registered: 10-10-2007

RE: Where to store PHP scripts

Can you explain why this so? F9's FAQ state:

"Don't upload PHP scripts to the cgi-bin directory of your webspace. You should store (save) them on your CGI webspace outside the cgi-bin directory, or you can create a separate folder for PHP files."

I use a folder structure outside the cgi-bin with htaccess if necessary. I can't get anything to work in the cgi-bin!

Thanks in advance,
Sword


> Neil, your original location for your files was fine, they do not need to be in your root - actually that's not a terribly clever place to put them.
>
> Placing them within a categorised directory structure beneath cgi-bin is fine.
>
> You probably have incorrect permissions set - you want to chmod 755 your script file PLUS you need to have execute permissions on your directory too - so if your script is in the following path
>
> cgi-bin/php/myscript.php
>
> you need to:
>
> chmod 755 cgi-bin/php/myscript.php
> chmod 755 cgi-bin/php
>
> I assume that cgi-bin has the correct permissions already - you'll only have to set your directory execute permissions once.
>
> Have you been using WS-FTP by any chance? If so dont fall into the trap of thinking that the CHMOD (UNIX) menu option displays the current permissions on the file - it displayes the LAST setting you used (at least it does at version 5.06) - its understandable when you think of how it is being done but a bit of a trap for unwary - particularly for windows users.
>
> There is another possible source of your problem that I have experienced before - if you ae using Internet Explorer and get a 403 No permission error and then reset the permissions correctly using say chmod - when you refresh the explorer view it doesnt always pick up the change correctly - even when you force a hard refresh. I have on occasion had to quit explorer and restart to get it to pick of the script correctly again.
>
> Hope this is of some help.
>
>
>