Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-03-2008, 02:05 PM
|
#1
|
|
LQ Newbie
Registered: Feb 2006
Posts: 21
Rep:
|
Why doesn't chmod -R 777 works?
I've a script that's suppose to change somethins in a folder.
The only problem is that the script don't 've writing wrtites to the folder.
Just to be clear.
First I've a .sh file thats start when the computer goes on. The script look like this.
Code:
while true; do
/var/www/script/script.php
sleep 60
done
It runs the script every 60 sec.
The script it self starts with this line:
#!/usr/bin/php5
Does this mean that the php5 binary runs the script?
The problem is that none of the scripts 've writing writes to the folder.
I've tried to chmod -R 777 on the folder, but it doesn't mater.
What rights should I give the folder?
|
|
|
|
09-03-2008, 02:29 PM
|
#2
|
|
Member
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Rep:
|
Looks like you're trying to run shell code through the php interpreter which won't work.
Try replacing the #!/usr/bin/php5 with
Quote:
#!/usr/bin/sh
or
#!/usr/bin/bash
|
Also, why not use cron to run your script every 60 seconds?
|
|
|
|
09-03-2008, 02:46 PM
|
#3
|
|
LQ Newbie
Registered: Feb 2006
Posts: 21
Original Poster
Rep:
|
Thanks for the replay.
I just notest that when the user www-data (apache2) creates a folder, then the php5 binary can't write to it. So I've to manual run chmod -R 777 on the folder.
How do I change the rights so that php5 can write to a folder apache has created? Is it possible to add them to the same grope, how if so?
OffT: Why I don't use cron is because the cript doesn't take <60 sec to run so if I run is as cron more then one script will be running at the same time. With my solution it will wait 60 seconds after it's finish. Maybe there is a better way, but this works fine for now.
EDIT: The script I'm trying to run is written in php. So the top line should be correct. If I run the script as root in a terminal it works perfect.
Last edited by Snouser; 09-03-2008 at 02:54 PM.
|
|
|
|
09-04-2008, 02:15 AM
|
#4
|
|
Guru
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,365
|
Since it's a shell script it should start with or whatever your shell is.
Now to run the php script from inside the shell script you should use the php command:
Code:
php /var/www/script/script.php
You can su to www-data before running the command above, or you can chown/chmod the folder created.
|
|
|
|
09-04-2008, 03:04 AM
|
#5
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
To solve permissions problems, you need to know:
1) the UID/GID of the process that wants access
2) the UID, GID, and permissions of the file/directory that (1) will be accessing
Please provide answers to (1) and (2).
|
|
|
|
09-04-2008, 03:10 AM
|
#6
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
Php being an interpreter like shells are and php accepting # as a comment character, I think it is valid to insert the following header to a php source file in order to have it being a php executable:
|
|
|
|
09-04-2008, 03:43 AM
|
#7
|
|
Guru
Registered: Aug 2005
Posts: 9,557
|
you Never,Never,never chmod -r 777 www-data (apache2) you just gave EVERY PERSON ON THE WEB FULL READ/WRIGHT/EXECUTE PERMISION to your server .
|
|
|
|
09-04-2008, 03:55 AM
|
#8
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
Quote:
Originally Posted by John VV
you Never,Never,never chmod -r 777 www-data (apache2)you just gave EVERY PERSON ON THE WEB FULL READ/WRIGHT/EXECUTE PERMISION to your server .
|
And what permissions do you advise for web applications that upload data? Apache needs write permission for such activities.
Access controls are generally used at a higher layer, but the underlying file system permissions must be set such that the web server can write if writing is to be allowed..
|
|
|
|
09-04-2008, 10:59 AM
|
#9
|
|
Guru
Registered: Aug 2005
Posts: 9,557
|
chown -R apache:apache www-data
chmod -R 755 www-data
|
|
|
|
09-04-2008, 05:39 PM
|
#10
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
John VV - since you've given apache ownership to the files/directories, you get exactly the behavior you said to avoid in post #7. Removing group write permission here serves no purpose with respect to apache, as it already owns the files so group ownership is unimportant. Removing access for Other users only prevents LOCAL users from making changes to the files.
Thus, your suggested permissions and ownership do not meet your stated criteria.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 10:17 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|