It is all about the permissions. The system user (www-data) who runs your web server must have read permissions to the folder htdocs
and to the whole path to this folder.
Here I will describe three ways how that could be done:
- The short way - just give enough permissions;
- The proper (according to my knowledge) way - using terminal and
/etc/fstab
;
- The easiest proper way - using GUI tool
Disks
.
1. Just give enough permissions
For this purpose open a terminal window and type:
sudo chmod 755 /media/rahul/
Or give these permissions through Nemo
as it is shown in the screenshot from the question. Please remember 777
is not the best choice.
2. Make the partition part of the static file system tree: /etc/fstab
Specify static mount point and mount the partition (device) with right permissions through /etc/fstab
:
1. Create an appropriate mount point - open a terminal window and type:
sudo mkdir /mnt/shared
2. Find the necessary preliminary information:
Find the partition (device) identification. Type sudo blkid
and recognize your target partition (device). Let's assume it is /dev/sda4
with UUID=142E875C2E873630
.
Find your user's uid
(user-id) and gid
(group-id). In the terminal type: id
. The result shall looks something like: uid=1000(rahul) gid=1000(rahul) groups=1000(rahul),..
For further, more complicated permissions settings the data for some other users will be needed, for example id www-data
will return: uid=33(www-data) gid=33(www-data),...
3. Edit your /etc/fstab
file as root (using sudo
) and add new line:
When the device/partition is formatted under NTFS
this new line could be:
/dev/sda4 /mnt/shared ntfs uid=1000,gid=33,nls=utf8,umask=0022,fmask=111 0 0
Where:
/dev/sda4
the partition (device) - by /dev
location or UUID
- that contain a file system.
/mnt/shared
the location where the above partition (device) will be mounted.
ntfs
the type of the target device file system.
uid=1000,gid=1000
will set ownership permissions for user and group rahul
; uid=1000,gid=33
will set ownership permissions for user rahul
and group www-data
.
nls=utf8
means Use UTF-8 for converting file names.
umask=0022
will set the permissions for all folders to drwxr-xr-x
or octal 755
.
fmask=111
will set the permissions for all files to -rw-rw-rw-
or octal 666
.
When the partition (device) is formatted under ext4
this new line could be:
/dev/sda4 /mnt/shared ext4 default 0 0
Ant the permissions of its content can be further managed as usual - chown
, chmod
, etc.
4. Save the edits of /etc/fstab
, and reload it: sudo mount -a
.
Important note! If this is an external (USB) device, if it is unplugged, an error will be appeared. The solution is: 1) Go to Recovery mode, 2) edit /etc/fstab
and 3) comment (#
) the line described above.
3. Make the partition part of the static file system tree: Disks
1. Open Dash and type Disks
:

2. Find your target device and select Edit Mount Options
:

3. Edit Mount Options and click on OK
:

4. Mount the device - click on the Play
button:

Further steps
1. Find the new location of your htdocs
folder. It should be something as:
/mnt/shared/xampp/htdocs
2. Edit your shared.conf
file:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName shared
ServerAlias www.shared.com
DocumentRoot /mnt/shared/xampp/htdocs
<Directory />
#etc ...
</Directory>
<Directory /mnt/shared/xampp/htdocs/>
#etc ...
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
3. Restart Apache2 and try to access your site.
Sources and further reading
sudo chmod -R 777 htdocs
but still same error – Rahul Sharma Apr 16 '17 at 17:07sda4
directory if i am setting the path of those directory/media/rahul/One/shared
– Rahul Sharma Apr 16 '17 at 17:23