Apache-2.2

ubuntu amp 禁止使用

  • December 5, 2011

我正在嘗試在 localhost 訪問我的網站,但我得到:

“禁止

您無權訪問此伺服器上的 /index.html。Apache/2.2.14 (Ubuntu) 伺服器在 localhost 埠 80"

我的 error.log 說:

PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 08:51:51 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 08:51:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:51:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:52:00 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:52:17 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:54:15 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:54:17 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:55:19 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:55:23 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 08:56:40 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:00:10 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:02:05 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:02:07 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:05:04 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:06:50 2010] [notice] SIGHUP received.  Attempting to restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:06:50 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:06:57 2010] [crit] [client 127.0.0.1] (13)Permission denied: /var/www/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun Jun 20 09:08:46 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html
[Sun Jun 20 09:08:59 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:08:59 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:09:47 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:09:47 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:09:54 2010] [notice] SIGHUP received.  Attempting to restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:09:54 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:09:55 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:09:55 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:15:28 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:15:28 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:16:51 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:16:51 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:16:52 2010] [notice] Graceful restart requested, doing restart
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Sun Jun 20 09:16:52 2010] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.2 with Suhosin-Patch configured -- resuming normal operations
[Sun Jun 20 09:17:04 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html
[Sun Jun 20 09:17:07 2010] [error] [client 127.0.0.1] (13)Permission denied: cannot read directory for multi: /var/www/
[Sun Jun 20 09:17:15 2010] [error] [client 127.0.0.1] PHP Warning:  Unknown: failed to open stream: Permission denied in Unknown on line 0
[Sun Jun 20 09:17:15 2010] [error] [client 127.0.0.1] PHP Fatal error:  Unknown: Failed opening required '/var/www/test.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
[Sun Jun 20 09:18:38 2010] [error] [client 127.0.0.1] (13)Permission denied: file permissions deny server access: /var/www/index.html

我 chown 到 myusername:myusername /var 和 /var/www,chmod 到 711 /var 和 751 /var/www,我嘗試在 /var 上遞歸 chowning 和在 /var/www 上遞歸 chmoding,但仍然沒有。

如何訪問我的網站?

更新:

var 和 www 是 chowned www-data:deltrem,var 是 chmoded 711,www 751,它仍然不起作用 :-(

var 上的遞歸 chowning(幸運的是)似乎沒有奏效

/var應該保持 chmod 755 和 root:root。沒有理由更改 /var。

對於**/var/www**試試:

chown -R myusername:www-data /var/www
chmod -R 755 /var/www

確保在創建文件時保留此權限。而且您可能需要將一些需要由 apache2 編寫的文件更改為 775。

**重要提示:**請注意,這樣做,任何有權訪問您的使用者帳戶的人都可以修改網站文件。

/var/www 需要被 apache 使用者讀取。在我的 Ubuntu 9.04 上,apache 執行為www-data.

更改 /var 中所有內容的所有權和權限並不是一件好事,您應該將其恢復原狀。

引用自:https://serverfault.com/questions/152932