0

I just re-installed my Mint system and now I can't get php to work. I've tested apache and it seems to be working just fine, entering localhost into the URL brings up that default page in /var/www/ but when I created a small php file called testphp.php with nothing but phpinfo() function between to opening and closing braces all I get from the browser is NOT FOUND The requested URL /testphp.php was not found on this server. Any ideas what might have changed? After re-installing all I did was enter sudo apt-get install apache2 and sudo apt-get install php5

3
Contributors
8
Replies
44
Views
2 Years
Discussion Span
Last Post by lewashby
0

Check the ownership and the permissions of the script, by writing the file into /var/www/ you probably used sudo, correct? That gave root:root to the script. Apache needs access to read and execute the file, so you can switch the group to www-data:

sudo chown root:www-data script.php

Then, if your user is part of the www-data group, you can change the permission to allow your edits without using sudo:

sudo chmod 775 script.php

The above is valid for development in localhost, not for production, in that case the rules must be more restrictive.

0

I just changed the group for www and all sub files to www-data but I'm still getting the same result. Any other ideas? I just found something by looking at the log file. It's looking in /var/www/html/file.php instead of just /var/www/file.php. I've never seen that before. Where is the apache config file I need to make that change in?

0

Check the settings of /etc/apache2/sites-available/default or in apache2.conf and adjust the DocumentRoot to your desired path, then reload apache.

0

I had to move all of my php and html files into /var/www/html/ instead of just /var/www/ and now it seems to be working just fine. I've never seen apache use /var/www/html/ by default before, why is it doing it now?

0

Recursive set owner www-data for all www directories:

sudo chown -R 33 /var/www

Recursive set user group to YOU for all www directories:

sudo chgrp -R 1000 /var/www

Recursive set properties for owner and group - execute directories and read-write files, but other users read files and execute directories (lower rw and upper X set read-write files such as 0644 and execute dir such as 0755):

sudo chmod -R ug=rwX,o=rX /var/www

This 3 lines you can write in to the shell script file e.g. "properties.sh" (the file properties set executable) and call this file from command line always when you insert new files in to the /var/www

Edited by AndrisP

0

Thanks guys. I'll take a look at changing the root in the config file. Is there any reason not to use a web folder in my home directory instead of /var/www/ ? So for I've changed the owner to myself and the group to www-data, moved everthing to /var/www/html/ and it's working, just don't like changing from www to html.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.