There are four things to consider with scripts, programs, CGIs, etc. on Turing:
1) file extension, 2) location, 3) ownership and 4) permissions.
The easy part. Give CGI files the extension .cgi
PHP files should have the extension .php
perl files should end with .pl
There are others, but you get the idea.
PHP files can be anywhere in your public_html directory.
CGI files are special. They can only be run from within a directory named cgi-bin. This directory needs to be inside your public_html directory. The full path to that directory being:
/home/username/public_html/cgi-bin. You may have to create the cgi-bin directory yourself.
The owner of these files should be of the form username:username. Use the ls -l command option to see permissions and group information on the files. So, if user joe has a php file in his public_html directory, the ownership would be joe joe and so on. More about this here.
(NOTE: When you created the cgi-bin directory, it may have been created with the owners set as username:www-data.
All the directories, from your home directory, through the public_html, and into any directories inside it, (including the cgi-bin directory) the permissions need to allow the world to execute (traverse) that directory. For any directory below public_html you can accomplish this by issuing the chmod command with o (other) + x (execute) from a prompt inside your public_html directory:
chmod o+x cgi-bin/
(or whatever is the correct directory name)
If your home directory or public_html directory need permissions set, you can do the same steps for them.
cd . (press return)
Then issue the command
chmod o+x public_html
If you find the need to set permissions on your home directory as well, you can’t do it with a chmod o+x joe more, but instead have to “call it by reference”, like so:
chmod o+x $HOME
CGI files themselves just need to be executable, which can be accomplished with the following command:
chmod +x filename
NOTE: All PHP, perl, and cgi-bin files and directories SHALL NOT BE group writeable. That’s a security nightmare. So, if you get a “500 Internal Server Error.” response from a web page, check that the group permissions are correct.
So, you need to change your permissions. Let’s use octal rather than symbolic notation, thus: chmod 711 filename.ext
Want to learn more about chmod and octal vs symbolic notation? Try this: http://permissions-calculator.org/