考虑以下Apache配置:
$ cat /etc/apache2/sites-available/yair.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/yair/code/business/public_html
<Directory /home/yair/code/business/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory />
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
public_html
目录的配置如下:
$ cat /etc/hosts
127.0.0.1 localhost
$ pwd
/home
$ ls -la | grep yair
drwxrwxrw- 49 yair www-data 4096 Mar 26 10:33 yair
$ cd yair/
$ ls -la | grep code
drwxrwxrw- 4 yair www-data 4096 Mar 26 09:10 code
$ cd code
$ ls -la | grep business
drwxrwxrw- 8 yair www-data 4096 Mar 26 09:11 business
$ cd business/
$ ls -la | grep public
drwxrwxrw- 6 yair www-data 4096 Mar 26 10:33 public_html
$ cd public_html/
$ ls -la | grep index.html
-rwxrwxrw- 1 yair www-data 4566 Mar 26 09:11 index.html
当我将DocumentRoot
更改为/var/www/
并将文件放在那里时,Apache会按预期提供服务。但是,使用上述配置Apache抱怨:
您无权访问此服务器上的/index.html。
可能是配置错误?这是在Ubuntu 13.10上。
答案 0 :(得分:1)
请尝试使用此代码:
<VirtualHost *:80>
DocumentRoot /home/yair/code/business/public_html
<Directory /home/yair/code/business/public_html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Directory />
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>