php log file access

Hello,
I would like to have a log file directory that I can read and write to, but I don't want people to be able to see the files from the web.  What do I have to do?
jackjohnson44Asked:
Who is Participating?
 
Jaime OlivaresSoftware ArchitectCommented:
Yes, almost any Web server has a "control panel" where you can configure some directories (or better all) to be read directly like Windows Explorer, then you can just access it though contained Web pages.
0
 
inq123Commented:
Hi jackjohnson44,

I would just use a directory that is unmapped on web server as log file directory.  Alternatively, you could always use .htaccess to control access or set passwords on directories to protect mapped directories.

Cheers!
0
 
Jaime OlivaresSoftware ArchitectCommented:
Just use any directory of your server.
Your Web configuration can avoid any visitor to access your specific directory though a browser or ftp.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
jackjohnson44Author Commented:
how do I configure this?

Is there something to do with the permissions?
0
 
inq123Commented:
let's say your personal web root is at /home/myname/public_html, then all you need to do is mkdir /home/log and have your php script read and write to files in that directory.  That newly created log directory is not even mapped on your web server and not under your web root, so no www user can view anything in it.
0
 
inq123Commented:
sorry, I meant you can mkdir /home/myname/log, which is the directory that you'd have file system permission to create.

If you're on Windows machine, same thing.  Just create a new directory that is not under your web server root directory, and let php read and write to it.
0
 
gnudiffCommented:
Note also that PHP has syslog() function that can write to the standard syslog files on Unix machines and to the Event log on Windows machines.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.