Skip to content
RIPE NCC member · Local Internet RegistryCall us on 020 3318 3449sales@hosting-telecom.uk

File and directory permissions, CGI scripts

Which permissions to give your website’s files and directories, why you should not use 777, and how to run a Perl or Python script.

Contents

On shared hosting, your website’s scripts run as your account. That means you do not need wide permissions — the ordinary ones are enough:

Directories755
Website files644
Files containing passwords (wp-config.php, .env)600 — only your account can read them
Scripts that run on their own (CGI)755
Warning Do not set permissions to 777, even if a script’s instructions tell you to. It fixes nothing, and it allows anyone to change the file. It is an opening for hackers.

You change permissions in cPanel: File Manager → right-click the file → Change Permissions. In FileZilla, right-click → “File permissions…”. On your own server, use the chmod command: chmod 644 file.

Perl and Python scripts

  • Put the script in the public_html/cgi-bin/ directory and set its permissions to 755.
  • The first line of the script is the path to the program that will run it: #!/usr/bin/perl or #!/usr/bin/python3.
  • The script must first output a header, for example print "Content-Type: text/html\n\n"; — otherwise you will get a 500 error.
  • If the script was written on Windows, convert the line endings or it will not run: Files from Windows: line endings.

Didn’t find the answer? Ask our support team — we’ll help.

Choose which cookies we may use. You can change your mind at any time with the “Cookie settings” link at the bottom of every page.

Necessary

Always active

They keep the site secure and remember your cookie choice. They don’t identify you.

Google Analytics counts visits and shows which pages people find useful, so we can improve the site. Which cookies