🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.www.server-side
4 messages
4 total messages Started by jivanmukta Thu, 16 Jun 2016 17:21
Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html
#61484
Author: jivanmukta
Date: Thu, 16 Jun 2016 17:21
17 lines
2238 bytes
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.
Re: Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html
#61508
Author: Grzegorz Staniak
Date: Thu, 16 Jun 2016 20:51
27 lines
2226 bytes
On 2016-06-16, jivanmukta@poczta.onet.pl <jivanmukta@poczta.onet.pl> wrote:
> 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.

Ustawiłeś katalog główny serwera jako bazę rozwiązywania URLi.
Spróbuj:

RewriteBase /~robert/

GS
-- 
Grzegorz Staniak <gstaniak _at_ gmail *dot* com>
Re: Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html
#61489
Author: Jivanmukta
Date: Fri, 17 Jun 2016 08:27
6 lines
997 bytes
Grzegorz Staniak wrote:
> Ustawiłeś katalog główny serwera jako bazę rozwiązywania URLi.
> Spróbuj:
> RewriteBase /~robert/

Dzięki za pomoc!
Re: Apache próbuje pobierać index.php z /var/www/html a nie z ~/public_html
#61485
Author: PawelS cbrbob(at)wbcd(dot)pl
Date: Sat, 18 Jun 2016 08:08
58 lines
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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads