
Я пытаюсь получить доступ к своему сайту на локальном хосте, но получаю:
"Запрещенный
У вас нет разрешения на доступ к /index.html на этом сервере. Apache/2.2.14 (Ubuntu) Сервер на локальном хосте Порт 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
Я сделал chowning для myusername:myusername /var и /var/www, установил chmoding для 711 /var и 751 /var/www, я попробовал рекурсивный chowning для /var и рекурсивный chmoding для /var/www, но по-прежнему ничего.
Как получить доступ к моему сайту?
ОБНОВЛЯТЬ:
var и www имеют права собственности www-data:deltrem, var имеет права chmoded 711, www 751, но это все равно не работает :-(
рекурсивный chowning на var (к счастью) похоже не сработал
решение1
/вардолжны остаться chmod 755 и root:root. Нет смысла менять /var.
Для/var/wwwпытаться:
chown -R myusername:www-data /var/www
chmod -R 755 /var/www
Убедитесь, что вы сохраняете эти разрешения при создании файлов. И вам, вероятно, придется изменить некоторые файлы на 775 для тех, которые должны быть записаны apache2.
Важный:Обратите внимание, что при таком подходе любой, кто имеет доступ к вашей учетной записи, сможет изменять файлы веб-сайта.
решение2
/var/www должен быть доступен для чтения пользователю apache. На моем Ubuntu 9.04 apache работает как www-data
.
Изменение владельца и прав доступа ко всему в /var — не самое лучшее решение, лучше вернуть все как было.
решение3
Под каким пользователем работает apache? Обычно он работает под пользователем 'httpd' или 'apache' (iirc), поэтому попробуйте chowning /var/www обратно этому пользователю. Не следует chowning -r /var - там будут другие вещи, которые захотят читать и писать там, что, вероятно, очень скоро доставят вам неприятности.