LinuxQuestions.org
Visit Jeremy's Blog.
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, 07: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 07:46 PM. Reason: added console output
 
Old 05-17-2012, 02: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, 09: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:51 PM
[SOLVED] apache (running in Ubuntu 10.10) can't access php files W_Chevezman Linux - Software 12 02-24-2011 04:14 PM
Grant Apache read access to a file? damgar Linux - Server 1 09-22-2010 12:13 PM
Run PHP shell_exec as root maneeshsethi Linux - General 5 12-30-2008 08:25 AM
PHP exec() and shell_exec() and SELinux Cottsay Programming 1 06-25-2005 10:47 PM

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

All times are GMT -5. The time now is 07:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration