Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Linux permissions in the context of web sites

Posted on 2016-09-26
9
Medium Priority
?
184 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:Torquil Beavis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 2000 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:Torquil Beavis
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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 

Author Comment

by:Torquil Beavis
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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 2000 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:Torquil Beavis
ID: 41818531
.. the directory with x as well, of course.
0
 

Author Comment

by:Torquil Beavis
ID: 41818534
Great! Thanks Dave.
0
 

Author Closing Comment

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

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

660 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