gpt4 book ai didi

apache2 外盘权限

转载 作者:行者123 更新时间:2023-12-04 18:58:00 24 4
gpt4 key购买 nike

目前我的电脑上有一个硬盘驱动器,里面有我的所有项目,我希望我的 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

最佳答案

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

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

在这里找到的解决方案: https://superuser.com/questions/174776/modify-fstab-entry-so-all-users-can-read-and-write-to-an-ext4-volume ,我允许他开车并准备好 :)
me@machine:~$ sudo chmod 777 /media/me -R
me@machine:~$ sudo -u www-data ls -la /media/me
total 12
drwxrwxrwx+ 3 root root 4096 ene 14 15:33 .
drwxr-xr-x 3 root root 4096 dic 25 13:41 ..
drwxrwxrwx 22 me me 4096 ene 2 00:36 2TB

关于apache2 外盘权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27713521/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com