How to protect a file on the web host

Posted on 2008-11-08
Last Modified: 2013-11-19
I have a PHP script that updates a counter in a file on my website.  Someone recently got into that sub-directory and destroyed the file.  I need to be able to allow users to execute the script, but not allow anybody into the directory so they can farkle things up.

How do I do this?
Question by:rmmarsh
    LVL 4

    Assisted Solution

    whats the OS? if its windows then you can change the ntfs pernissions to read and execute, if its linux i think you need to chmod the file
    LVL 12

    Accepted Solution

    Could you give the server specification? A linux server or a windows server?

    If Linux, the give only the 755 right to the directory with its contents...

    You can change permissions for all files and directories within a directory by using the -R option on the chmod command. For example, to setup others read and execute access to all files and directories (and files and directories within directories), you need to type command as follows (i.e. change the modes of the file hierarchies rooted in the files instead of just the files themselves):
    # chmod -R 755 directory-name/

    Files that you create in the public_html dir must have at least permissions
    644 (directories must be 755) or the WWW server will not be able to read
    them and they will not be "on the World Wide Web".

    Best regards...

    LVL 12

    Assisted Solution

    Does the counter file need to be in a directory that's served by the web server? The app that updates it needs to be able to write to it, but it doesn't need to be in a directory that could possibly be accessed through a browser.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    The first time you look at a web page and its source code, you are probably a little intimidated by the use of symbols and jargon that really looks foreign to you. You might not even know where to start to begin learning what it all means. That’…
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now