I have a set of PHP 5 scripts that I wrote on a Windows dev server and am now setting up on a LAMP dev server. I am not an expert on Linux, though, but I want to use it for security reasons. The hosting site will be a LAMP server. I'm trying to run administrative processes remotely and am having some trouble with accessing files. Assume the following directory structure:
.../testsite.com/ contains an htpasswd file
.../testsite.com/docroot/ contains main scripts that everyone accesses
.../testsite.com/docroot/log/ contains text log files plus an htaccess file
.../testsite.com/docroot/includes/ contains php include files, Swiftmailer scripts plus an htaccess file
.../testsite.com/docroot/admin/ contains php admin files plus an htaccess file
The task is to tie in remotely to the hosting site and execute an administrative php script that opens, writes to and closes a log file in the /log subdirectory above as well as accesses the database and also sends emails.
Option 1 was to try and execute the php admin script by opening a browser, going to .../testsite.com/docroot/admin and executing the access file on the LAMP dev server. I entered the username and password assocatied with htaccess and start to execute the script. However, it fails because it can't open the file:
Warning: fopen(.../testsite.com/docroot/log/AdminTest-2009-09-07.txt) [function.fopen]: failed to open stream: Permission denied in .../testsite.com/docroot/admin/test2.php on line 29
Couldn't open the output file.
Option 2 was to try and execute the php admin script from the command line on the LAMP dev server (as an admin). I used the command 'php -f .../testsite.com/docroot/admin/test2.php. However, it fails because it can't open the header file that is in another directory (the includes directory outlined above). The error message mentioned another path (include_path='.:/usr/share/php:/usr/share/pear'), although my php.ini file sets the include path to .../testsite.com/docroot/includes/ as mentioned above.
How can I execute these admin scripts remotely in a secure way?
Thanks.
remotely running PHP admin programs
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: remotely running PHP admin programs
I'm not exactly sure what you want, but it sounds like you are having some permission issues. Are you sure PHP can access your log files?
Re: remotely running PHP admin programs
After further work on this, I found that it is a permission issue. I can create a file ahead of time and change the permissions on it and it will write to the file. The problem has to do with the fact that I build a file name on the fly (with today's date, etc.), but I'm not sure how to set the right permissions on the fly.
Thanks.
Thanks.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: remotely running PHP admin programs
Make the folder writable and it should work. You can also try to use chmod().
Re: remotely running PHP admin programs
thanks for your help