newbie: Apache/PHP configuration in Linux

newbie: Apache/PHP configuration in Linux

am 30.11.2007 08:14:33 von r_ahimsa_m

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 :

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/

Re: newbie: Apache/PHP configuration in Linux

am 30.11.2007 10:08:42 von phantom

"R.A.M." wrote in message
news:fiod91$o7c$1@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

> 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.

Re: newbie: Apache/PHP configuration in Linux

am 30.11.2007 10:10:12 von phantom

"R.A.M." wrote in message
news:fiod91$o7c$1@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

Re: newbie: Apache/PHP configuration in Linux

am 30.11.2007 12:21:14 von r_ahimsa_m

U¿ytkownik "phantom" napisa³ w wiadomo¶ci
news:uqQ3j.55400$c_1.13046@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/