Article View: pl.comp.www.server-side
Article #61485Re: Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html
From: PawelS cbrbob(at)wbcd(dot)pl
Date: Sat, 18 Jun 2016 08:08
Date: Sat, 18 Jun 2016 08:08
58 lines
3502 bytes
3502 bytes
jivanmukta@poczta.onet.pl pisze:
> Używam Apache2 z userdirs pod Ubuntu.
> Mam w /home/robert/public_html aplikację PHP (CodeIgniter).
> Adres localhost/~robert/index.php działa. Adres localhost/~robert/index.php/announcement/index również.
> Chciałbym usunąć index.php z urla. W tym celu zmodyfikowałem plik ~robert/public_html/.htaccess, tzn dopisałem:
>
> RewriteEngine On
> RewriteBase /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond $1 !^(index\.php|robots\.txt|denial\.html|resources|captcha)
> RewriteRule ^(.*)$ index.php/$1 [L,QSA]
>
> Adres localhost/~robert otwiera się.
> Problem: przy próbie otwarcia localhost/~robert/announcement/index mam 404 Not found.
> W error.log'u Apache'a mam: script '/var/www/html/index.php' not found or unable to stat.
> Nie wiem dlaczego Apache próbuje pobierać index.php z /var/www/html a nie z ~robert/public_html.
> Byłbym wdzięczny za pomoc.
Temat był już poruszany na pl.comp.www,
tak jak napisałeś:
> Na serwerze hostingowym działa OK, problem jest z localhostem.
> Chyba mam coś nie tak Apachem...
Poniżej konfiguracja, która powinna zadziałać:
/etc/httpd/httpd.conf
LoadModule userdir_module modules/mod_userdir.so
<IfModule mod_userdir.c>
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#UserDir disable
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#UserDir public_html
UserDir WWW
</IfModule>
Opcjonalnie można dodać (zgodnie z zakomentowanym przykładem):
<Directory /home/*/WWW>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
DirectoryIndex index.html index.html.var index.php
</Directory>
Uprawnienia dla katalogów są istotne (SELinux może spowodować 403):
drwxr-xr-x root root system_u:object_r:root_t:s0 //
drwxr-xr-x root root system_u:object_r:home_root_t:s0 /home/
drwx--x--x sp users user_u:object_r:user_home_dir_t:s0 /home/sp/
drwxr-xr-x sp users root:object_r:httpd_sys_content_t:s0 /home/sp/WWW/
-rw-r--r-- sp users root:object_r:httpd_sys_content_t:s0 /home/sp/WWW/index.php
http://example.org/~sp/
http://example.org/~sp/index.php
powyższe wywołania działają zgodnie z tym czego oczekujesz.
Technical Details
Message-ID:
<nk2via$e47$1@node1.news.atman.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mailReferences:
<1a783e36-616b-4c0f-86c9-d757d3542a2d@googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail From: "PawelS cbrbob(at)wbcd(dot)pl" <fake@email.org> Newsgroups: pl.comp.www.server-side Subject: Re: Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html Date: Sat, 18 Jun 2016 10:08:42 +0200 Organization: ATMAN - ATM S.A. Lines: 58 Message-ID: <nk2via$e47$1@node1.news.atman.pl> References: <1a783e36-616b-4c0f-86c9-d757d3542a2d@googlegroups.com> NNTP-Posting-Host: host-89-231-96-70.warszawa.mm.pl Mime-Version: 1.0 X-Trace: node1.news.atman.pl 1466237322 14471 89.231.96.70 (18 Jun 2016 08:08:42 GMT) X-Complaints-To: usenet@atman.pl NNTP-Posting-Date: Sat, 18 Jun 2016 08:08:42 +0000 (UTC) User-Agent: Thunderbird 2.0.0.24 (X11/20110622) In-Reply-To: <1a783e36-616b-4c0f-86c9-d757d3542a2d@googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit