LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-16-2012, 06:43 PM   #1
jamesj629
LQ Newbie
 
Registered: Jan 2008
Posts: 14

Rep: Reputation: 0
PHP shell_exec and running as apache? how to grant access to some of the filesystem?


Hi all,

I need to run the following PHP line:

Code:
echo shell_exec('/root/visitors_0.7/visitors -A -m 30 -o html /var/log/httpd/access_log');
I know apache runs as user 'apache' on my server and currently it gives me "permission denied" errors because all the files are owned by root.

What's the best way of giving permission to just these files so it can run?

Or perhaps there is a better way?



Here's my setup:
cloud server on rackspace
CentOS
PHP 5


ls -lh ~/visitors_0.7/
-rwxr-xr-x 1 root root 264K May 15 20:34 visitors

ls -lh /var/www/html/s/
-rw-r--r-- 1 root root 224 May 16 23:16 index.php



Thanks

Last edited by jamesj629; 05-16-2012 at 06:46 PM. Reason: added console output
 
Old 05-17-2012, 01:34 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
You can set uid permissions on that script but your best option would be to use suphp.

www.suphp.org
http://www.howtoforge.com/apache2_suphp_php4_php5

http://www.tuxation.com/setuid-on-shell-scripts.html
 
1 members found this post helpful.
Old 05-17-2012, 08:11 PM   #3
jamesj629
LQ Newbie
 
Registered: Jan 2008
Posts: 14

Original Poster
Rep: Reputation: 0
Talking

Quote:
Originally Posted by Kustom42 View Post
You can set uid permissions on that script but your best option would be to use suphp.
http://www.tuxation.com/setuid-on-shell-scripts.html
suphp does indeed look good - thank you kind sir.

Compiling a setuid() C program works like a charm, and this is my short term solution.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP shell_exec with parameters is not working nikeshp Linux - Software 5 01-19-2012 06:51 PM
[SOLVED] apache (running in Ubuntu 10.10) can't access php files W_Chevezman Linux - Software 12 02-24-2011 03:14 PM
Grant Apache read access to a file? damgar Linux - Server 1 09-22-2010 11:13 AM
Run PHP shell_exec as root maneeshsethi Linux - General 5 12-30-2008 07:25 AM
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 09:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration