php installation error in ubuntu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

php installation error in ubuntu

Post by lipun4u »

I have recently shifted from windows to ubuntu.

I have successfully installed php+apache by following steps..
sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart
Now I put a file known as script1.php in /var/www/ folder which contains

Code: Select all

 
<?php
 
print "hello World";
 
?>
 
But when tried in the address bar http://127.0.1.1/script1.php
it gave me following problem...
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

Fatal error: Unknown: Failed opening required '/var/www/script1.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php installation error in ubuntu

Post by requinix »

Does /var/www have read and execute permissions for the right user/group? (I think it runs as apache, wheel, or www-user.) How about script1.php?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: php installation error in ubuntu

Post by VladSun »

What is the output of:

Code: Select all

ls -l /var/www/script1.php
There are 10 types of people in this world, those who understand binary and those who don't
lipun4u
Forum Commoner
Posts: 82
Joined: Wed Jul 01, 2009 3:35 am
Location: Mumbai
Contact:

Re: php installation error in ubuntu

Post by lipun4u »

Ya I got this

I gave the rwx permission on the file.

Is this possible to automate this procedure or change the default permission of all files created in this /var/www/ folder ???
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php installation error in ubuntu

Post by requinix »

Your umask should be 0022, so new directories should automatically be 0755 and new files will be 0644.

Create a new PHP file, make sure that it doesn't work (with the same problem as before) then do as VladSun asked - but replace the script1.php with whatever the new file was named.
Post Reply