我需要授予我的“网络浏览器用户”权限才能运行代码

I am writing web pages using PHP and would like to "require" code that I have written (in the future I would also like to be able to run python code).

whoami gives: www-data 
require '/fullpath/code.php';

The error I get is:

 require(/fullpath/code.php): failed to open stream: Permission denied

So the user www-data doesn't have permission to run my code. How do I give it permission? Also, how do I do this without opening up the can of worms giving hackers access to my web programs?

I have sudo privileges but I've never heard of the user www-data I do sudo find . | grep www-data (from the "/" directory) and I get nothing. So I'm not even sure where to find this "user" to change its permissions.

Thanks

www-data is one of the users that web servers run as. You don't need to change its permissions for it to access your code - you need to change your code's.

The easiest way to do that is to make your code world-readable - something like:

chmod -R 644 /fullpath

will do it.

chmod changes permissions; -R makes it run recursively; 644 sets the permissions to readable for Group and World (and you get Read, Write privileges); and the final parameter is the path to run this on.

You'll need to check that you don't have anything in that directory that you need Execute permission for, as the code as written will remove that permission and you'll need to add it back in.