CGI scripts and programs (such as .cgi, .pl or .py files) can run on our Web Hosting (Plesk) plans. This article covers where to upload them, which permissions to use, and what to do if you see a 403 Forbidden or 500 Internal Server Error.
Before you start
-
CGI must be turned on for your domain. In Plesk, go to Websites & Domains > Hosting Settings. Under Web scripting, make sure CGI is checked, then save.
- Your program must support 64-bit Linux. Our servers run 64-bit Linux, so programs built only for Windows, or for older systems, won't run.
Step 1: Upload the script to the cgi-bin folder
Upload your CGI script or program to the cgi-bin folder of your domain using File Manager or an FTP program (with FTP with TLS/SSL).
For compiled programs and installers, use Binary transfer mode. If an FTP program uploads a program in ASCII or Auto mode, the file can be damaged and won't run.
- FileZilla: go to Transfer > Transfer type > Binary before uploading.
- To check the upload: compare the file size on your computer with the size on the server. They should match exactly.
Step 2: Set the correct permissions
| Item | Permission |
|---|---|
| cgi-bin folder | 755 |
| CGI scripts and programs | 755 |
You can change permissions in File Manager (click the file's permissions) or in your FTP program.
Note: setuid permissions (4755) aren't allowed on our servers for security reasons. They also aren't needed, because CGI scripts already run under your own hosting account. If a program's instructions ask for 4755, use 755 instead.
Step 3: Run the script
Open it in your browser, for example:
https://yourdomain.com/cgi-bin/yourscript.cgi
Step 4: Delete installers when you're done
If you ran an installer script (for example, a setup or install .cgi file), delete it once the installation is complete, so no one else can run it.
Common errors
403 Forbidden
The server isn't allowed to open the file or folder. Check that:
- CGI is turned on for your domain (see Before you start).
- The cgi-bin folder is set to 755.
- The script is set to 755, not 4755.
500 Internal Server Error
The server opened the script, but it stopped running. Common causes:
- The file was damaged during upload. Upload it again in Binary mode, and check the file size.
- The program isn't compatible with 64-bit Linux. Ask the program's developer for a version that supports 64-bit Linux.
-
The script's first line is incorrect. For scripts such as Perl or Python, the first line tells the server which program runs the script (for example,
#!/usr/bin/perl). Check that it's correct. - The script was saved with Windows line endings. Scripts edited on Windows should be saved with Unix (LF) line endings. Most code editors have this option when saving.
Frequently asked questions
-
Can I use 4755 (setuid) permissions?
No. Setuid programs aren't allowed on our shared hosting for security reasons. Use 755. Your scripts already run under your own account. -
My program worked on my old hosting. Why doesn't it work now?
Older programs may have been built for an older system. Our servers run a current 64-bit Linux system, so some older programs need an updated version from their developer. -
Can you install or fix a CGI program for me?
We can check that CGI is turned on and that your folder and file permissions are correct. Installing, configuring or fixing the program itself is handled by you or the program's developer. -
Where should I upload CGI scripts?
We recommend uploading CGI scripts to your domain's cgi-bin folder.
Comments
0 comments
Please sign in to leave a comment.