How to protect a file on the web host

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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Hugh FraserConsultantCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.