Reputation: 691
I'm running Debian 7 on my VPS and I want to have a PHP scripting that would allow me to do the following thing:
I have a MTA server and I have logfiles in a separate directory (/root/mta/resources/logs
) and the website is obviously in /var/www
, how would I go around moving the log.txt
file from the MTA location to /var/www
?
Is it possible to do this via PHP only or .sh
would also be required ?
Upvotes: 0
Views: 74
Reputation: 50190
If you want to move a file from point A to point B using php, just use system
to execute the appropriate mv
or ln
command line. There's no need for all the error-checking in the script you link to (in your comments).
Before you do it, find out (a) whether this particular log file can safely be placed under the document root, (b) whether you really need to put it there (why not just access it where it lives now?), and (c) whether it's even going to work: if you simply move the file, you can expect the server to create a new one.
You should probably be asking about how to solve your actual problem, because this doesn't sound like a solution you ought to succeed at.
Upvotes: 1
Reputation: 4952
Try to do a symbolic link with: ln -s /root/mta/resources/logs/log.txt /var/www/log.txt
For security issue you can add a .htaccess
:
<Files /var/www/log.txt>
Order Allow,Deny
Deny from all
</Files>
Upvotes: 1