LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-04-2009, 03:41 AM   #1
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Rep: Reputation: 31
Question How to allow user other than root to write php script?


Hello friends,

As a root user I can write and run php scripts in /var/www/html but when I log-in as a user other than root, I am not allowed to write/update/create etc files. Please suggest some solution.

Regards.
 
Old 10-04-2009, 06:18 AM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 99
The permissions on the /var/www/html directory determine who can create and
delete files in that directory. Any existing files have their own permissions.

Plan who should have write access to these files, since they will be able to
break your website or your server, whether accidentally or intentionally.
 
Old 10-04-2009, 11:49 AM   #3
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Thank you cery much carltm.
So how can I give the create/change/delete etc permission mq15 (the user other than root)?
[In fact I am myself the root user of my system but I log into fedora not as root user but as mq15 for security reasons. This was suggested by someone at this forum.]
 
Old 10-04-2009, 12:12 PM   #4
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
change the owner or change permissions for the directory /var/www/
 
Old 10-04-2009, 12:34 PM   #5
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Thanks mobinskariya but I don't know how to change permissions for /var/www/ directory...
 
Old 10-04-2009, 12:40 PM   #6
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
its simple read manual.
Code:
man chown
man chmod
if u find it urself u r goin to learn it quickly..if u encounter any problem come back here again and we will try to solve it.

good luck
 
Old 10-04-2009, 01:11 PM   #7
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Oh, that was a good way to make me learn myself...

So will
Quote:
[root@localhost ~]# chmod +x /var/www/
grant execute permissions to user? Here I am confused where to specify the user name i.e. mq15 in this command.
 
Old 10-04-2009, 01:27 PM   #8
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
Quote:
Originally Posted by mq15 View Post
Oh, that was a good way to make me learn myself...

So will
grant execute permissions to user? Here I am confused where to specify the user name i.e. mq15 in this command.
i think u want to write some files and may b add some files in the future in /var/www/,, what you have to do change the ownership of the directory ..u must be logged in as root for performing the following
Code:
chown -R user:group /var/www/
substitute user and group with your username and groupname


then change the permissions
Code:
chmod -R u+rwx /var/www/
above code means give the read(r), write(w), and execute(x) permission to the directory owner.. -R means recursively change the permission and so permission for all the files in the subdirectories will also change..

hope that helps

Last edited by mobinskariya; 10-04-2009 at 01:30 PM.
 
Old 10-05-2009, 08:00 AM   #9
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Thanks
First: There are two users on my system:1.root and 2.mq15. So I don't know what will I have to substitute with group in this command:
Quote:
chown -R user:group /var/www/
Second:When the ownership will be changed from root to mq15, will not root be able to perform read/write operations in /var/www/ directory? I want root just to share the read/write permissions with mq15 in /var/www/ and keep the ownership with root.
 
Old 10-05-2009, 08:24 AM   #10
mobinskariya
Member
 
Registered: Sep 2007
Location: Kerala, India
Distribution: ubuntu 10.04
Posts: 367

Rep: Reputation: 55
even if you dont use group it wont affect..so you may use
Code:
chown -R user /var/www/
imo root is able to do anything he wants in the system..so there wont be any problems for your root to read, write or execute anything anywhere anytime in your machine..
 
Old 10-05-2009, 01:08 PM   #11
mq15
Member
 
Registered: Apr 2009
Location: Pakistan
Distribution: Linux Mint Cinnamon
Posts: 224

Original Poster
Rep: Reputation: 31
Thank you very much mobinskariya..and see I have not forgotten clicking the blue thumbs up icon..
 
  


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
How can I have a script owned as root and run as root by a user: setuid? stickey bit? abefroman Linux - Newbie 9 04-19-2008 05:15 PM
How can I write this sing (') in my php script? ice99 Programming 5 12-04-2006 06:43 AM
write a PHP code to run some command as ROOT ??? tritong Programming 13 02-22-2006 10:48 PM
Slackware 10.0 Samba: root can write, user cannot bhicks Slackware 15 11-18-2004 11:46 PM
php script can not write text file lemotion Linux - Newbie 5 04-20-2004 10:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:40 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