Where should PHP scripts go?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Where should PHP scripts go?


    Hi folks,

    In developing a website containing both HTML files and PHP files, I had
    thought that it was good practice (or even mandatory depending upon
    webserver configuration) that the PHP files should reside in a cgi-bin
    directory. However, when I did a quick test on webspace that's being hosted
    for me (using Apache if that makes any difference), a PHP script placed in
    the cgi-bin directory doesn't work, yet placed outside of that directory, it
    runs fine.

    Based on my limited understanding, this seemed to me to be exactly the wrong
    way around, but when I put this point of view to the hosting company's
    customer services, they said:

    ----------
    Its a cgi bin. For CGI scripts. PHP does not work like that.

    basically the CGI-bin is a safe place to store CGI scripts. It won't ever
    display the source code.. whereas if you put it outside the cgi-bin..and if
    u have an error..it has the ability to display the source.

    PHP wont display the source unless you specifically display it.
    ----------

    Sadly, I don't think I really understand this reply. Could anyone throw some
    light on my misunderstanding, or perhaps easier still, does anyone know of
    any guide or tutorial to laying out (in terms of directory structure) a
    website?

    I've tried what I consider to be reasonable search phrases, but don't seem
    to be able to find any documentation that addresses my questions.

    Thanks for any assistance,
    A.


    Andrew C. Guest

  2. Similar Questions and Discussions

    1. php scripts
      Does anyone know of like some customizeable script that allows me to have one icon if there is a user logged in and another if nobody the user is not...
    2. How di I use scripts?
      I found a great paginating script, but I have no idea how to use it. Thanks (script below) myPages = app.documents.pages; // Let's make sure...
    3. CS: Scripts do not appear in Scripts menu
      I have several utility AppleScripts that I created for Illustrator 10. I'd like to use these in CS, and they work correctly when I choose "Browse"...
    4. scripts that control other scripts
      Is there any behaviour script that when attached to a sprite can control the functionality of any other scripts attached to that sprite? I want to...
    5. ASP scripts from IIS 4 to IIS 5
      > Set objLog = objFile.OpenTextFile(Server.MapPath Do you have the Norton and/or McAfee Viruses (err, anti-virus products) installed?...
  3. #2

    Default Re: Where should PHP scripts go?

    Andrew C. wrote:
    > Hi folks,
    >
    > In developing a website containing both HTML files and PHP files, I had
    > thought that it was good practice (or even mandatory depending upon
    > webserver configuration) that the PHP files should reside in a cgi-bin
    > directory. However, when I did a quick test on webspace that's being hosted
    > for me (using Apache if that makes any difference), a PHP script placed in
    > the cgi-bin directory doesn't work, yet placed outside of that directory, it
    > runs fine.
    >
    > Based on my limited understanding, this seemed to me to be exactly the wrong
    > way around, but when I put this point of view to the hosting company's
    > customer services, they said:
    >
    > ----------
    > Its a cgi bin. For CGI scripts. PHP does not work like that.
    >
    > basically the CGI-bin is a safe place to store CGI scripts. It won't ever
    > display the source code.. whereas if you put it outside the cgi-bin..and if
    > u have an error..it has the ability to display the source.
    >
    > PHP wont display the source unless you specifically display it.
    > ----------
    >
    > Sadly, I don't think I really understand this reply. Could anyone throw some
    > light on my misunderstanding, or perhaps easier still, does anyone know of
    > any guide or tutorial to laying out (in terms of directory structure) a
    > website?
    >
    > I've tried what I consider to be reasonable search phrases, but don't seem
    > to be able to find any documentation that addresses my questions.
    >
    > Thanks for any assistance,
    > A.
    >
    >
    hey andrew,

    personally i don't put my php-files in a protected directory, only the
    files with valuable information (passwords, ...) are protected in a
    private-directory (protected with .htaccess).

    now, i suggest you make a directory and do a quick search on .htaccess
    (google gives good results on this one, or this NG too).


    normally i work like this:
    private-directory for all valuable php-files
    web-directory:
    - style (all css)
    - images (all images)
    - php-files (all php-files)
    - html-files
    - directory's for other sites (more sites on one server)

    untill now it works fine for me, no problems at all.

    hope this covers a part of your question...

    cheerz and good luck,
    thomas
    thomas L. Guest

  4. #3

    Default Re: Where should PHP scripts go?

    "Andrew C." <backwards.moc.senrocwerdna@swenaret.backwards> wrote in message
    news:aef8b0cabfdc9584ef45f323e625dc08@news.teranew s.com...
    >
    > Hi folks,
    >
    > In developing a website containing both HTML files and PHP files, I had
    > thought that it was good practice (or even mandatory depending upon
    > webserver configuration) that the PHP files should reside in a cgi-bin
    > directory. However, when I did a quick test on webspace that's being
    hosted
    > for me (using Apache if that makes any difference), a PHP script placed in
    > the cgi-bin directory doesn't work, yet placed outside of that directory,
    it
    > runs fine.
    >
    > Based on my limited understanding, this seemed to me to be exactly the
    wrong
    > way around, but when I put this point of view to the hosting company's
    > customer services, they said:
    >
    > ----------
    > Its a cgi bin. For CGI scripts. PHP does not work like that.
    >
    > basically the CGI-bin is a safe place to store CGI scripts. It won't
    ever
    > display the source code.. whereas if you put it outside the cgi-bin..and
    if
    > u have an error..it has the ability to display the source.
    >
    > PHP wont display the source unless you specifically display it.
    > ----------
    >
    > Sadly, I don't think I really understand this reply. Could anyone throw
    some
    > light on my misunderstanding, or perhaps easier still, does anyone know of
    > any guide or tutorial to laying out (in terms of directory structure) a
    > website?
    With PHP files, you just put the files anywhere you like--just like HTML
    files. This is because when a user accesses a PHP file on the server, a
    complier program on the server compiles the page before sending to the user.
    What the user sees is essentially just an HTML page (well, of course, PHP
    could also generate HTML pages with e.g. Javascript, but that's besides the
    point.)

    Jonathan
    > I've tried what I consider to be reasonable search phrases, but don't seem
    > to be able to find any documentation that addresses my questions.
    >
    > Thanks for any assistance,
    > A.

    Jonathan Christensen Guest

  5. #4

    Default Re: Where should PHP scripts go?


    Thomas and Jonathan -- thanks for your advice.

    I guess I just had (and still have probably) a misunderstanding about what
    cgi-bin directories are for, but at least now I know that PHP doesn't belong
    there. :)

    Thanks again!

    A.


    Andrew C. Guest

  6. #5

    Default Re: Where should PHP scripts go?

    It's depend on how is configured Apache, and how is run PHP, as CGI or as
    Module.

    PHP can be both CGI or module, it's just different the way the server handle
    the page. In a few words, take CGI as a program PHP is run everytime to read
    the code then is closed after, while Module is the PHP is already loaded
    with the server and is waiting to read a PHP page when needed.

    That's why CGI files must be within a special directory with the Permission
    Execute (cgi-bin). Module dont need Permission Execute, and will work will
    php normally, that's why you can put it anywhere.

    That's also why C++ and Perl are also CGI.

    Savut

    "Andrew C." <backwards.moc.senrocwerdna@swenaret.backwards> wrote in message
    news:6a51657be569c5ac8f84d7ac73607d8b@news.teranew s.com...
    >
    > Thomas and Jonathan -- thanks for your advice.
    >
    > I guess I just had (and still have probably) a misunderstanding about what
    > cgi-bin directories are for, but at least now I know that PHP doesn't
    > belong
    > there. :)
    >
    > Thanks again!
    >
    > A.
    >
    >
    Savut Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139