apache2外部磁盘权限

问题描述 投票:0回答:2

当前,我的电脑上有一个硬盘,用于处理所有项目,我希望我的apache服务器通过虚拟主机链接我的所有项目,但拒绝访问,原因是问题在于它不是主磁盘,所以我可以关于吗?

例如:

我使用ubuntu 14.04

root@MS-7817:/# cat /etc/apache2/sites-available/demo.conf 
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName demo.local

    DocumentRoot /home/me/public_html/demo
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/me/public_html/demo/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

启用站点:

me@MS-7817:/etc/apache2/sites-enabled$ ll
total 8
drwxr-xr-x  2 root root 4096 dic 30 17:01 ./
drwxr-xr-x 10 root root 4096 dic 28 03:13 ../
lrwxrwxrwx  1 root root   35 dic 27 20:02 000-default.conf -> ../sites-available/000-default.conf
lrwxrwxrwx  1 root root   28 dic 30 17:01 demo.conf -> ../sites-available/demo.conf

执行:

$ ln -s /media/myuser/projectdisk/demo/www/ /home/myuser/public_html/demo

应用于主机:

root@MS-7817:/# cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   MS-7817

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.0.1   demo.local

文件存在:

root@MS-7817:/# cd /home/me/public_html/demo
root@MS-7817:/home/me/public_html/demo# ll
total 100
drwxrwxr-x 2 www-data www-data  4096 dic 30 16:30 ./
drwxrwxr-x 5 me       me        4096 dic 29 13:49 ../
-rw-rw-r-- 1 me       me        12921 dic 30 16:30 index.php

我使用正确的权限:

me@MS-7817:/$ id
uid=1000(me) gid=1000(me) grupos=1000(me),4(adm),24(cdrom),27(sudo),30(dip),33(www-data),46(plugdev),108(lpadmin),124(sambashare)

正确重新启动Apache:

me@MS-7817:/$ sudo service apache2 restart
[sudo] password for me: 
 * Restarting web server apache2
 * 

但无法访问http://demo.local/

Forbidden

You don't have permission to access / on this server.
Apache/2.4.7 (Ubuntu) Server at demo.local Port 80
apache ubuntu apache2 file-permissions symlink
2个回答
2
投票

它们是文件权限的问题,默认的ubuntu挂载磁盘具有当前用户www-data的只读权限,而没有读取权限:

me@machine:~$ sudo -u www-data ls -la /media/me
ls: no se puede abrir el directorio /media/me: Permiso denegado

0
投票

我有类似的问题我想让apache访问我的外部硬盘上的文件,但我收到错误403权限被拒绝的信息。

© www.soinside.com 2019 - 2024. All rights reserved.