Python script basics
Learn the essentials of using Python on ruachost.com servers, including file permissions, extensions, and running different Python versions.

This article provides guidance for working with Python script files on ruachost.com servers.

What permissions do I need to set for my Python script files?
The correct permissions depend on the script’s function:

  • Python CGI scripts (publicly accessible via the web): set permissions to 755 (read, write, execute for the user; read and execute for group and world). Do not give world write permissions.

  • Command-line-only Python scripts: set permissions to 700 (read, write, execute for the user; no permissions for group and world).

What file extensions can I use for Python scripts?
Python scripts can use .py or .cgi, depending on their purpose:

  • CGI scripts generating web output for public access use .cgi.

  • Scripts run only from the command line, or scripts not generating web output, use .py.

  • Tip: To use .py for CGI scripts, you must configure an Apache handler.

What version of Python is installed on ruachost.com servers?
To check the default Python version, run:

python -V

What is the path to the Python executable?
The default Python executable is located at /usr/bin/python. Since /usr/bin is in the default path, you can usually run Python scripts without specifying the full path:

python filename

Running different Python versions
Multiple Python versions are available. To see them, run:

ls /usr/bin/python*

To run a script using Python 3, for example, type:

python3 filename

Note: Shared and Reseller servers offer a Python Selector in cPanel to switch Python versions. On CentOS 7 shared/reseller servers, the Python Selector is the only method to use different Python versions.

Can I use the mod_python Apache module?
mod_python is not supported on shared hosting accounts. On VPS or dedicated servers, you can install and use mod_python.

More information
For official Python documentation, visit Python Docs.

Hasznosnak találta ezt a választ? 0 A felhasználók hasznosnak találták ezt (0 Szavazat)

Powered by WHMCompleteSolution