考慮以下Apache配置:阿帕奇不是服務於/主頁,但正確地投放在/ var頁
$ 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上。
你從服務器訪問呢? – krowe
是的,我正在從Firefox瀏覽器訪問與http:// localhost/index.html'相同的機器。這是一個獨立的臺式機。 –
如果你仍然遇到這個問題,你會發布Apache錯誤日誌嗎?另外,當你訪問'/ index.php'時,它是否會在文件中添加一個條目:'/ var/log/apache2/access_logs'? – krowe