newbie: Apache/PHP configuration in Linux

Hello,
I use Fedora 7 Moonshine and I need to learn PHP5. I have already had
Apache and PHP packages installed:
$ rpm -q httpd
httpd-2.2.4-4.1.fc7
$ rpm -q php
php-5.2.2-3
In my home directory I have created /home/robert/www folder, and
I have created PHPHelloWorld subfolder with hello.php simple PHP page:
$ ls /home/robert/www/PHPHelloWorld
hello.php
As you guess hello.php contains simple command in <body>:
<?php echo "Hello, world!"; ?>
Then I have entered modifications according to description found in
Internet.
In /etc/php.ini I have changes the lines:
error_reporting = E_ALL | E_STRICT
doc_root = /home/*/www
In /etc/httpd/conf/httpd.conf I have changed/added the lines:
UserDir /home/*/www
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
and I have restarted httpd:
$ httpd -k restart
I thought that now I can use browse my hello.php page, but when I enter
in Mozilla:
http://localhost/~robert/PHPHelloWorld/hello.php
I receive the following result:
Forbidden
You don't have permission to access
/~robert/PHPHelloWorld/hello.php on this server.
Apache/2.2.4 (Fedora) Server at localhost Port 80
My question is: what else I should do?
Please help, I have little experience.
/RAM/
r_ahimsa_m [ Fr, 30 November 2007 08:14 ] [ ID #1882829 ]

Re: newbie: Apache/PHP configuration in Linux

"R.A.M." <r_ahimsa_m [at] poczta.onet.pl> wrote in message
news:fiod91$o7c$1 [at] news2.task.gda.pl...
> In my home directory I have created /home/robert/www folder, and
> I have created PHPHelloWorld subfolder with hello.php simple PHP page:
> $ ls /home/robert/www/PHPHelloWorld
> hello.php
<SNIP>
> http://localhost/~robert/PHPHelloWorld/hello.php
> I receive the following result:
> Forbidden
> You don't have permission to access
> /~robert/PHPHelloWorld/hello.php on this server.
> Apache/2.2.4 (Fedora) Server at localhost Port 80
> My question is: what else I should do?

By default your home directory and everything inside will not be accessible
by the apache user...

ls -ld /home
will probably give something like this:
drwxr-xr-x 129 root root 4096 Nov 28 12:48 /home

ls -ld /home/robert
will probably give this
drwx------ 129 robert robert 4096 Nov 28 12:48 /home/robert

which means user robert can do everything, group robert is not allowed and
neither is anyone else.
change /home/robert so that others can at least access it (but not read it)
chmod o+x ~robert
and allow read access to the directory (and its subdirectories) you want
apache to be able to see, either by allowing everyone read access to it:
chmod -R o+rx ~robert/www
or by changing the group of the folder to apache and allowing that group to
have read access
chgrp -R apache ~robert/www
chmod -R g+rx ~robert/www

However, I'd also check the apache conf file to ensure that 'www' is the
correct folder (search for the UserDir directive as it is generally a
directory called 'public_html' not 'www'.

Also, this is a little quick and dirty - you'll be giving execute
permissions to files too (could be a security risk, depending upon what is
actually in those directories)

AND - I'm also ignoring the possiblity of you having SELinux enabled, this
adds extra security hurdles for you to overcome.
phantom [ Fr, 30 November 2007 10:08 ] [ ID #1882830 ]

Re: newbie: Apache/PHP configuration in Linux

"R.A.M." <r_ahimsa_m [at] poczta.onet.pl> wrote in message
news:fiod91$o7c$1 [at] news2.task.gda.pl...
> In /etc/httpd/conf/httpd.conf I have changed/added the lines:
> UserDir /home/*/www

oops, sorry, missed that bit - although I think it should be

UserDir www
phantom [ Fr, 30 November 2007 10:10 ] [ ID #1882831 ]

Re: newbie: Apache/PHP configuration in Linux

Użytkownik "phantom" <nobody [at] blueyonder.invalid> napisał w wiadomości
news:uqQ3j.55400$c_1.13046 [at] text.news.blueyonder.co.uk...
> By default your home directory and everything inside will not be
> accessible by the apache user...
> ...

Success! Thank you, you have helped me.
/RAM/
r_ahimsa_m [ Fr, 30 November 2007 12:21 ] [ ID #1882833 ]
Webserver » alt.apache.configuration » newbie: Apache/PHP configuration in Linux

Vorheriges Thema: Reverse Proxy with mod_proxy_html to IIS
Nächstes Thema: Universal htaccess across all VirtualHosts?