Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: changing privilege to access certain directory

  1. #1
    Join Date
    Oct 2012
    Beans
    42

    Question changing privilege to access certain directory

    The root owns www directory, what would be the way to let a user have access to that directory? Do I need to change permissions by "chmod" directive and if I need to take it back use the same process?
    Thanks.

  2. #2
    Join Date
    Oct 2012
    Beans
    185

    Re: changing previlage to access certain directory

    Quote Originally Posted by workaround View Post
    The root owns www directory, what would be the way to let a user have access to that directory? Do I need to change permissions by "chmod" directive and if I need to take it back use the same process?
    Thanks.
    If the machine is used in a single user environment, I don't think doing a chown (not chmod) on www will make any difference on apache's working however it will make editing easy for you.

    You can also leave www as it is and setup a virtual host on your prefered location. Infact setting up virtual host is more appropriate if you intend to develop more than one sites.

  3. #3
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: changing previlage to access certain directory

    Quote Originally Posted by workaround View Post
    The root owns www directory, what would be the way to let a user have access to that directory? Do I need to change permissions by "chmod" directive and if I need to take it back use the same process?
    Thanks.
    i think you can change it to belong to group www-data . that will give user the necessary access.

    and then if necessary add user to the group: http://www.cyberciti.biz/faq/ubuntu-...roup-www-data/
    Easy to understand Ubuntu manual with lots of pics: http://ubuntu-manual.org/
    Do i need antivirus/firewall in linux?
    User friendly disk backup: Redobackup

  4. #4
    Join Date
    Jan 2005
    Location
    South Africa
    Beans
    2,098
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: changing previlage to access certain directory

    Code:
    sudo chgrp yourprimaryusergroup /var/www
    sudo chmod 775 /var/www
    The first command makes that the group of the file is going to be your primary group. The second command will set the permissions correct so the users in the group have full access.

    As an alternative, you can use setfacl which allows more fine-grained control.

    But the, in my opinion, best solution is to NOT use /var/www. Just put the files for a website in a user's home directory and point the document root to it (for a single site) or use virtual hosts (as mentioned by pkadeel) with document roots somewhere in user's home directories.
    Last edited by Wim Sturkenboom; November 13th, 2012 at 11:17 AM.
    If you don't make backups of your important data, your data is obviously not important to you.

  5. #5
    Join Date
    Oct 2012
    Beans
    42

    Re: changing previlage to access certain directory

    Well, to "pkadeel", how would I set up the virtual host? Ubuntu changed the setup for Apache and that changed the environment for virtual hosting, I do not modify any more
    Code:
    httpd.conf
    like used to!?
    I got two Apache servers on my machine, the Ubuntu that is running while using the Ubuntu configuration and the old setup Apache that does not want to load PHP due to the conflict with "mod_unixd.so". I would like to remove this one but I am not sure what trouble I might run into again of reconfiguring all to get it to work.
    I did consider 775 mode but the root owns the directory and so it does not allow me (the user) to use it without the sudo!?
    The only way I see it is to use 777 mode on the www directory(!?), not sure about that.

  6. #6
    Join Date
    Oct 2012
    Beans
    185

    Re: changing previlage to access certain directory

    Quote Originally Posted by workaround View Post
    Well, to "pkadeel", how would I set up the virtual host? Ubuntu changed the setup for Apache and that changed the environment for virtual hosting, I do not modify any more
    Code:
    httpd.conf
    like used to!?
    I got two Apache servers on my machine, the Ubuntu that is running while using the Ubuntu configuration and the old setup Apache that does not want to load PHP due to the conflict with "mod_unixd.so". I would like to remove this one but I am not sure what trouble I might run into again of reconfiguring all to get it to work.
    I did consider 775 mode but the root owns the directory and so it does not allow me (the user) to use it without the sudo!?
    The only way I see it is to use 777 mode on the www directory(!?), not sure about that.
    Creating a virtual host is a very simple and straight forward procedure. You don't have to modify any existing file just an apache restart would be required.

    create a new blank file. Name it "your_site_name". Put the following text in it making the changes required.
    Code:
    <VirtualHost 127.0.0.1:80>
        ServerName yoursite_domain_name
        ServerAdmin admin@yoursite_domain_name
        DocumentRoot /full/path/to/your/site/root
        <Directory  /full/path/to/your/site/root/>
            Options Indexes FollowSymLinks
            IndexOptions FancyIndexing
            AllowOverride All
            Order Deny,Allow
            Allow from all
        </Directory>
        DirectoryIndex index.php index.html
    #    RewriteLog ${APACHE_LOG_DIR}/sitename-rewrite.log
    #    RewriteLogLevel 5
        ErrorLog ${APACHE_LOG_DIR}/sitename-error.log
        CustomLog ${APACHE_LOG_DIR}/sitename-access.log combined
    </VirtualHost>
    If the site is being used for development purpose only and is accessed from localhost then you can use a dummy domain name like "mysite.loc" and put its entry in /etc/hosts file on a new line.
    Code:
    127.0.0.1               mysite.loc
    Now put this file in /etc/apache2/sites-available folder and enable it. You can also check it for errors before apache2 restart. code is included below.
    Code:
    sudo cp /path/to/newfile /etc/apache2/sites-available
    sudo a2ensite your_site_name
    sudo apache2ctl -S
    sudo service apache2 restart
    As far as changing permissions is concerned, I said earlier that chmod doesn't apply here. what you need is chown (means change the owner of the www folder.)
    Last edited by pkadeel; November 13th, 2012 at 07:18 PM.

  7. #7
    Join Date
    Sep 2006
    Beans
    8,627
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: changing previlage to access certain directory

    The www-data user and group are reserved for privilege separation of the web server's processes. If you are sharing access to the vhost, then you'll need a group, such as 'webmasters'

    Code:
    # do once
    sudo addgroup webmasters
    sudo chgrp -R webmasters /var/www
    
    sudo find /full/path/to/your/site/root/ -type d -exec chmod g=rwxs "{}" \;
    sudo find /full/path/to/your/site/root/ -type f -exec chmod g=rws "{}" \;
    
    # repeat for each user:
    sudo gpasswd --add workaround webmasters

  8. #8
    Join Date
    Oct 2012
    Beans
    42

    Question Re: changing privilege to access certain directory

    I get error while calling: sudo a2ensite mfspace.net
    Code:
    ERROR: Site mfspace.net does not exist!
    Code:
    <VirtualHost 127.0.0.1:80>
        ServerName mfspace.net
        ServerAdmin admin@mfspace.net
        DocumentRoot /home/pesh/workspace/public_html
        <Directory  /home/pesh/workspace/public_html/>
            Options Indexes FollowSymLinks
            IndexOptions FancyIndexing
            AllowOverride All
            Order Deny,Allow
            Allow from all
        </Directory>
        DirectoryIndex index.php index.html
    #    RewriteLog ${APACHE_LOG_DIR}/mfspace-rewrite.log  // sitename-error.log
    #    RewriteLogLevel 5
        ErrorLog ${APACHE_LOG_DIR}/mfspace-error.log
        CustomLog ${APACHE_LOG_DIR}/mfspace-access.log combined
    </VirtualHost>
    I did setup the hosts:
    Code:
    # 127.0.0.1    localhost
    127.0.0.1       mfspace.net
    127.0.1.1    one
    ...
    The directory is created and it has an index.php file.
    Also, I changed the path but still don't get the right results.
    Thanks much.

  9. #9
    Join Date
    Oct 2012
    Beans
    42

    Re: changing privilege to access certain directory

    I renamed the file from mfspace to mfspace.net in sites-available and it works BUT it still conflicts with something!?
    This is the output:
    Code:
    pesh@one:/etc/apache2/sites-available$ sudo service apache2 reload
     * Reloading web server config                                                  
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    Any suggestion why is not reconfiguring?

  10. #10
    Join Date
    Jan 2005
    Location
    South Africa
    Beans
    2,098
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: changing privilege to access certain directory

    That's just a warning. It is reconfigured and should now work.
    If you don't make backups of your important data, your data is obviously not important to you.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •