4

Agenda: To have an common Project Folder between Linux and Windows

I have changed my document root from : /var/www/html to /media/mithun/Projects/test in my ubuntu machine 14.04

I get error as :

Forbidden

You don't have permission to access / on this server.

Apache/2.4.7 (Ubuntu) Server at localhost Port 80

So i added some scripts to : sudo gedit /etc/apache2/sites-available/000-default.conf

# DocumentRoot /var/www/html
  DocumentRoot /media/mithun/Projects/test

But Document Root /var/www/test works but not with Windows NTFS Partition Drive.

Even after referring to :

  1. Error message "Forbidden You don't have permission to access / on this server"
  2. Issue with my Ubuntu Apache Conf file. (Forbidden You don't have permission to access / on this server.)

No success :( So kindly assist me with it...

Note: Projects is an New Volume (Internal Drive: In Windows its E:/ Drive)

@Lmwangi - Please check my updates for your reference below:

Output of : ls /etc/apparmor.d/

abstractions    lightdm-guest-session  usr.bin.evince         usr.sbin.cupsd
cache           local                  usr.bin.firefox        usr.sbin.mysqld
disable         sbin.dhclient          usr.lib.telepathy      usr.sbin.rsyslogd
force-complain  tunables               usr.sbin.cups-browsed  usr.sbin.tcpdump

I tried killing apparmor:

sudo /etc/init.d/apparmor kill

I receive output as : Usage: /etc/init.d/apparmor {start|stop|restart|reload|force-reload|status|recache}

After this, i was also able to restart apache successfully

Community
  • 1
  • 1
Mithun Shreevatsa
  • 3,588
  • 9
  • 50
  • 95
  • Step 1 is to read the error_log. – covener May 17 '15 at 12:18
  • Start your apache server in single processor/debug mode. Attach strace to it and find out the exact syscall that's throwing the error. Can you paste that into your question? – Lmwangi May 23 '15 at 20:54
  • On another note, you can try something like sudo -u www-data "ls /media/mithun/Projects/test". My gut feeling is that you have apparmor or selinux or something similar blocking you :) – Lmwangi May 23 '15 at 20:56
  • Hi @Lmwangi - I tried with `sudo -u www-data "ls /media/mithun/Projects/test"`. It threw command not found error. – Mithun Shreevatsa May 24 '15 at 10:11
  • Oops, just remove the quotes. Should be sudo -u www-data ls /media/mithun/Projects/test or better sudo -u www-data strace ls /media/mithun/Projects/test – Lmwangi May 25 '15 at 08:57
  • Do you have apparmor or selinux installed? Try running dpkg -l | egrep "armo|seli" – Lmwangi May 25 '15 at 09:03
  • @Lmwangi - I Got this output : `ii apparmor 2.8.95~2430-0ubuntu5.1 amd64 User-space parser utility for AppArmor ii dh-apparmor 2.8.95~2430-0ubuntu5.1 all AppArmor debhelper routines ii libapparmor-perl 2.8.95~2430-0ubuntu5.1 amd64 AppArmor library Perl bindings ii libapparmor1:amd64 2.8.95~2430-0ubuntu5.1 amd64 changehat AppArmor library ii libselinux1:amd64 2.2.2-1ubuntu0.1 amd64 SELinux runtime shared libraries ` – Mithun Shreevatsa May 25 '15 at 17:56
  • Assuming that you don't need apparmor server wide, try to disable apparmor or uninstall it. If you need it, you can edit the Apache specific config to whitelist your /media/mithun/... path. Odds are, Apache will start serving your files after disabling/adjusting app armor (and possibly restarting Apache). Have a look at http://ubuntuforums.org/showthread.php?t=875986 or https://help.ubuntu.com/lts/serverguide/apparmor.html or https://help.ubuntu.com/community/AppArmor. If this works, let me know – Lmwangi May 27 '15 at 13:48

4 Answers4

1

maybe the problem is simple : is your new root directory accessible to the www-data user ? Try :

$ chown -R www-data:www-data /media/mithun/Projects
axellink
  • 128
  • 1
  • 9
  • Hi tried your code. Its throwing error as : "chown: changing ownership of ‘/media/mithun/Projects’: Operation not permitted" – Mithun Shreevatsa May 12 '15 at 14:12
  • try it in root. Also if you want to see if it's the real problem, try ls -la /media/mithun/Projects and look at third and 4th columns if they are set to www-data (do the same for folders inside the Projects one) – axellink May 12 '15 at 14:19
  • I did not see it it was a windows partition ... This will be way more complicated ... Is your project going to be accessible online ? If not try to chmod 777 all your files – axellink May 17 '15 at 08:25
  • Sorry for not putting it earlier as windows partition. After a down vote, i analysed it to be clean and clear with all the possible efforts put into it. I tried setting permission with 777, still no dice :( Do i need to assign 777 permission for /media/mithun/Projects complete directory or /media/mithun/Projects/test (where project folder exists) – Mithun Shreevatsa May 17 '15 at 08:27
  • It is now quite obvious it should be a right problem because of the NTFS partition. Maybe you should try one of these solutions here : http://stackoverflow.com/questions/14864944/how-do-i-give-apache-permission-to-use-a-directory-on-an-ntfs-partition – axellink May 17 '15 at 12:18
  • And also you should do chmod 777 -R /media/mirhun/Projetcs – axellink May 17 '15 at 12:21
1

As you have you have discovered by now, you cannot just manipulate permissions on an NTFS partition (using tools like chmod)

However, you can try forcing a given owner/permissions for the entire partition when you mount it.

Now the wayto do this, depends on the NTFS-utilities you are actually using (and which i don't know, so I'm assuming you are using ntfs-3g)

E.g. mount the partition with the following parameters (replace dev/sdX with your actual partition, and /path/to/wheredrive/is/mounted` with your target path):

  mount -o gid=www-data /dev/sdX /path/where/the/drive/is/mounted 

should make all the files on the partition belong to the www-data group.

If the filesystem sets the group ownership explicitely, this still might not work. In this case, you might need to setup a usermap, that maps your windows users/groups (as found on the partition) to your linux users/groups.

The ntfs-3g.usermap utility will help you generate an initial usermap file, which you can then edit to your needs:

 ntfs-3g.usermap /dev/sdX

Then pass the usermap to the mount options:

  mount -o usermapping=/path/to/usermap.file /dev/sdX /path/where/the/drive/is/mounted 
umläute
  • 28,885
  • 9
  • 68
  • 122
  • i tried with ur first step of `mount -o gid=www-data /dev/sdX /path/where/the/drive/is/mounted` But failing in 2nd step - It throws error as `Could not open "/dev/sda1" Make sure "/dev/sda1" is not mounted`. I also unmounted using **Gparted** – Mithun Shreevatsa May 23 '15 at 09:01
  • I accepted the answer because of the efforts, but its not yet solved yet. Please assist with it as my bounty points was going to expire today. So thought of not wasting it in vain – Mithun Shreevatsa May 24 '15 at 09:09
0

I suspect that you have apparmor enforcing rules that prevent Apache from reading non-whitelisted directory paths. I suggest that you

  1. Edit the apparmor config for Apache to access your custom path. You'll need to hunt around /etc/apparmor.d/ . You may also find that using apparmor in non-enforcing mode helpful.

    $ sudo aa-complain /etc/apparmor.d/*

  2. Use mod_apparmor? See this

  3. Or disable apparmor completely. See this

My order of preference would be 1,3,2. That should fix this for you :)

Lmwangi
  • 2,486
  • 1
  • 19
  • 26
0

While using ubuntu with windows I faced same issue and it is resolved by remounting drive with read and write access. Below command will help you to do that:

sudo mount -o remount,rw /disk/location /disk/new_location

If it is still not working then in windows os, go to the power options and disable fast startup.

When you shut down a computer with Fast Startup enabled, Windows locks down the Windows hard disk. You won’t be able to access it from other operating systems if you have your computer configured to dual-boot. Even worse, if you boot into another OS and then access or change anything on the hard disk (or partition) that the hibernating Windows installation uses, it can cause corruption. If you’re dual booting, it’s best not to use Fast Startup or Hibernation at all.

Original article: https://www.howtogeek.com/243901/the-pros-and-cons-of-windows-10s-fast-startup-mode/

siraj pathan
  • 1,455
  • 1
  • 14
  • 31