public_html and PHP

11.09.2018 - 12:54

Note! LabraNet usename corresponds to userid with your LabraNet username when running the commands below.

Every LabraNet user has public_html folder under their home folder.

To publish websites, first you have to modify some rights of your homefolder.

[userid@student userid]$ chmod 701 ~

This command gives only the execute permission to others.

[userid@student userid]$ chmod 705 ~/public_html

Note! Remember to apply permissions recursively if you have a nested folder structure under your public_html folder.

[userid@student userid]$ chmod -R 705 ~/public_html

With the above commands you allow others to read and execute your public_html folder.

[userid@student userid]$ touch ~/public_html/index.html

Note! Unless run chmod recursively, permissions do not apply to .htaccess. This file needs to be readable. To fix this, allow read permission to others.

[userid@student userid]$ chmod 604 ~/public_html/.htaccess

Now you should see an empty page @ http://student.labranet.jamk.fi/~userid

For PHP functionality check instructions in .htaccess -file under public_html. More information can be found in instructions-directory in your home folder.

500 Internal Server Error

1. Check that your scripts syntax is right. Run “php -l my_script.php” on command line (where my_script is your php file).

2. Check that your public_html folder has correct permissions (see above).

3. SELinux context might be wrong. Restore the SELinux context by issuing command:

chcon -R -v -t httpd_user_content_t ~/public_html/*