Ispmanager 6 lite, pro, host documentation

Working with Python

 

Python – a general-purpose programming language that can be integrated to run websites and applications.

To add a Python project, follow these steps:

Before importing users with Python, make sure that the target server has all the correct versions of Python installed.

Install Python

Note!
In order to add the ability to install Python to the ispmanager control panel, you must first install Nginx web server. Note that installing Nginx will change the configuration of the web servers. If you have already configured sites in ispmanager using the Nginx+Apache bundle, it is recommended to contact the developer of the sites to clarify the possibility of correct operation after Nginx installation.

To enable:

  1. In the Main menu select Settings.
  2. From the drop-down list select Software configuration.
  3. On the form that opens, select Python from the list and click on Install.

Once the installation is complete, Python will become available as a handler when you create the site.

Enable Python

1. Python is disabled for users by default after installation.

2. To enable, go to Users  Edit.

3. On the Access tab, enable Can use Python.

4. Set the default Python version in Default values tab.

5. Press Save.

Note!
Default Python version can be configured in user templates.

Users with the ability to create Python websites are indicated by a green icon in the Status column.

 

Configure user

Once Python is installed on the panel, add usage rights to the user under which Python projects will be added, to do this:

  1. In the Main menu select Users.
  2. Select the appropriate user and click on Edit.
  3. On the form that opens, find the Access section.
  4. Enable the Python checkbox and click the Save button.

After saving, a Python icon will be displayed in the user Status column.

Create a website for a project with Python

Now you need to create a site with a Python handler, to do this:

  1. In the Main menu select Sites.
  2. On the form that opens click Create website.
  3. Select the Extended settings tab (for a detailed description of the settings, see Add a website) and fill in the required fields. Below are the important fields when creating a website with a Python project:
    • Main settings section:
      • Domain name – the domain name;
      • Website directory – the path to the website directory that is relative to the owner's home directory;
      • Website aliases – the names of the aliases you want to add to your website (optional field);
      • Handler – select Python;
      • SSL certificate – select an SSL certificate that will be used for this website. You can specify the existing certificate or create a new self-signed certificate;
      • IP address – a list of IP addresses assigned to the website;
      • Website owner – select the website owner;
      • Default website (checkbox) – if the website is marked as default, it will process a request by the domain name which is not registered on this webserver (including requests by IP) to any IP address assigned to this website;
    • Handler (Python) section:
      • Application mode:
        • CGI (Apache + Python) – Python interpreter is called by Apache2, the code will be executed by accessing the file directly;
        • Python web server– some Python packages need server configuration (for example, Django). Configure after the appropriate package is installed:
          • Path to server – the path to the application server file relative to the home directory of the website;
          • Server arguments – list of arguments that will be passed to the server at startup;
          • Connection method (method selection is only available when Python Web Server mode is selected):
            • Port – free unprivileged port will be assigned to the website;
            • Socket file – the website will work via a socket.
        • Python version – select the required Python version.
  4. Click on Create.

On the Sites page, the created website will be added with the Python icon in the Parameters column.

Add a Python project

Add your Python project to the created site by doing the following:

  1. In the Main menu select Sites.
  2. Select the required site and click on the Website files button.
  3. On the File Manager form that opens, click Upload.
  4. Select where you want to upload the files from:
    • Local computer file – click on Choose file or move the necessary files to the drag-and-drop area;
    • File URL on remote server:
      • URL – a link to the file to be uploaded, for example, http://example.com/dir/file.html;
      • File name – the name of the file to be saved with in the current directory. If you leave this field blank, the file name will be extracted from the URL.
  5. Specify the required packages in the requirements.txt file.
  6. Click on Back to the list of websites arrow.
  7. Click on ““ and select Installing Python packages.
    Python will install all the specified packages of your project. The installation process is indicated by a gray Python icon in the Parameters column.
  8. After installation is complete, click on the ““ button and select Restart (Python).
    The project will be restarted; the Python icon will turn green, which means the project is working properly.
If you have installed a Python package that requires Web server configuration:
  1. Configure the website by clicking Edit.
  2. Navigate to the Handler section and fill in the fields for Python web server.
  3. After filling in the fields, click on the Save button.
  4. If necessary, configure the installed Python package.

Functional check

To check if it works:

  • If the Unix family OS is installed on the PC, add the following entry to the /etc/hosts file:
    1.1.1.1 example.com
    Where:
    • 1.1.1.1 — is the IP-address of your server;
    • example.com — the website name;
  • If Windows OS is installed on the PC, add the following entry to the C:\windows\system32\drivers\etc\hosts file:
    1.1.1.1 example.com
    Where:
    • 1.1.1.1 — is the IP-address of your server;
    • example.ru — the website name.

Enter the name of the website in your browser to check if it was created correctly.