Solved

Linux permissions in the context of web sites

Posted on 2016-09-26
9
176 Views
Last Modified: 2016-09-27
Hi:
I have read and reread a number of articles on permissions and know how to change them, yet I find that I cannot place them in the context of web site development and usage. I do not have access to the server directly since I use a remote Linux shared server.

As the only developer, I am creating a web site with PHP. I need to create directories and files which I transfer through an FTP app on my desktop. All of the web site scripts and data files are in the URL-accessible server directories, except the uploads directory that is private (between the URL-accessible web directory and the root directory).
Directory structure:
/
-private directory (Non-URL accessible - for uploads)/
    -files
    -sub-directory/
        -files
-web directory (URL accessible)/
    -sub-directory/
        -files
        -sub-sub-directory/
            -files

Open in new window

There are three types of user:
1. The only developer, where I create directories and files, use the web site app, upload image files from the web site and the FTP app, and manage the directories and files through FTP.
2. The web site user, who uses the web site forms and reads data on the web pages. They may not upload any files. They have no personal access to the directories and files.
3. Specific web site users, that is registered members, are like user 2. except they may upload image files to the server.

What is an permission 'owner'? Me as developer, the server, or the scripts?
What is a 'group'? Me as a developer, only other developers if there were some, registered members?
And is 'other' the regular non-registered users - ie anybody using the app?

For each of these groups 1 through 3, what would be the rwx permissions for the directories and files that they have access to?
If another developer joins me and I want to have secure directories and files that this second developer must not have, how would this change the permissions?

Much appreciated :)
0
Comment
Question by:krotb
  • 5
  • 4
9 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 41817407
Normally with shared hosting you set the permissions thru the FTP account.  You are normally the owner.  There are no other users on the server except for 'root' which you do not have access to and the web server user which is a very limited user.  For any other limits on access, you will have to create those in your code.

To get more actual Linux users for finer control over the file permissions, you would have to get your own server.  I have not seen any shared hosting that will allow that.
0
 

Author Comment

by:krotb
ID: 41817819
So does this mean that all my directories and files should have group and other as --- ? Including upload directories and files?
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 41818146
No.  If you did that no one would be able to access them thru the web server.  Using my own site as an example, 'normal' file permissions are -rw--r--r (644) which allows you to write files and others to read them.  Directories must have the 'x' bit set as shown in the image below.
Linux permissions
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:krotb
ID: 41818501
Ah! Great.
Just to clarify ..
If my users need to upload images, which would be writing to the server, would that mean assigning rw-  to the 'upload' directory and file under 'group' or 'other' or neither?
0
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 500 total points
ID: 41818522
Users upload files to a PHP script, not directly to a directory.  Writing to the final directory is normally done by enabling 'suexec' on the server.  That allows your PHP scripts to write uploaded files to the required directories under your permissions.  

On shared hosting, 'group' is almost useless.  'World' or 'other' is what web site visitors are under and it is almost Never a good idea to enable them to directly write anything.  Most of the time there is no way for them to do it anyway.
0
 

Author Comment

by:krotb
ID: 41818531
.. the directory with x as well, of course.
0
 

Author Comment

by:krotb
ID: 41818534
Great! Thanks Dave.
0
 

Author Closing Comment

by:krotb
ID: 41818595
Dave, that's the best explanation I've ever read. Thank you.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41818614
You're welcome, glad to help.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How do uses indexes to maximize MySQL Searches 14 54
Email called spam 5 36
PHP and MSSQL Arrays and Variables 3 22
Accessing specific element - DOM PHP HTML 8 34
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question