Python Selector

Note

This documentation is for the old version of Python Selector. You can find documentation for the new Python Selector Beta below

We have the ability to deploy Python applications via application server. Python Selector uses mod_passenger to host Python.

This feature is available for CloudLinux 6 or later. It supports only cPanel servers.

You can find a list of supported alt-python versions using the following command.

yum grouplist | grep alt-python

Python Selector Installation

Note

The instructions below are suitable only for EasyApache 3 and EasyApache 4. You should follow this instruction if you use LiteSpeed.

Install tools to create isolated Python environments and Passenger Apache module. For servers with EasyApache3:

yum install lvemanager alt-python-virtualenv alt-mod-passenger

for EasyApache4:

yum install lvemanager alt-python-virtualenv ea-apache24-mod-alt-passenger

To use Python Selector you should install alternative Python packages:

yum groupinstall alt-python

To use MySQL database you should install alt-python27-devel package:

yum install alt-python27-devel

Note

After installation, please make sure that you have unmarked appropriate checkboxes in LVE Manager Options tab to show Python App in web-interface.

Note

Adding Python modules requires executing permissions to gcc/make binaries. Please enable compilers in Compiler Access section of WHM, then run: cagefsctl --force-update

End User Access

  1. In Software/Services area choose Select Python Environment.

  1. Create project form will appear. Choose interpreter version for your application, application folder name (project path) and URI for accessing your application. Click “Create project” to create an application.

After a little while a new application entry will be appended to the web-page.

  1. You can edit path (folder name of the project in the home directory, for example, /home/clman1/project_name ), uri for application, wsgi handler. If you click Edit - the value is converted to input field and thus becomes editable. When editing is complete, click Save .

  1. Wsgi entry is to specify python wsgi application entry point. It must be specified as filename, must be callable and separated by colon. If your app is running from file flask/run.py by calling callable app, set flask/run.py:app .

  1. When Show control is clicked, python extensions section will be expanded. It gives the ability to add or remove python modules. When start typing in input field, appropriate hints are shown in drop-down list. Choose the entry you want from drop-down and click Add .

If you click Delete , the corresponding module entry will disappear. In addition to setting path, uri and wsgi , the interpreter version can be changed as well by changing the value in select drop-down.

  1. No changes are applied to application environment until Update button is clicked. Before the Update button is clicked, all changes can be reverted with Reset button.

The newly created application will be supplied with stub only. A real application ought to be put into application folder. After application is placed into application folder, the wsgi parameter can be set.

Click Remove to delete the application - the application folder itself will remain unmoved.

Note. For LVE Manager version 0.9-10 and higher:

When creating an application you can use the key --domain , which attaches application to domain. If --domain key is not specified, then the main users domain will be used by default. To create application run:

/usr/bin/selectorctl --interpreter=python --version=VERSION[--user=USER] [--domain=DOMAIN] [--print-summary] [--json]–-create-webapp <FOLDER_NAME> <URI>

When changing application URI, --domain key can be used simultaneously, in this case not only URI will be changed, but also the application domain.

To change application URI run:

/usr/bin/selectorctl --interpreter=python [--user=USER][--domain=NEW_DOMAIN] [--print-summary] [--json] --transit-webapp<FOLDER_NAME> <NEW_URI> 

The possibility to choose domain when creating an application was added to web interface as well.

Also, you can run simple commands from web interface (e.g. you can install packages from specific repositories or control web applications by means of django -admin).

Command Line

All the actions mentioned in Deploy and Settings section can be performed from the command line:

To create application run:

/usr/bin/selectorctl --interpreter=python --version=VERSION [--user=USER] [--print-summary] [--json] --create-webapp <FOLDER_NAME> <URI>

To delete application:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --destroy-webapp <FOLDER_NAME>

To change application folder name:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --relocate-webapp <FOLDER_NAME> <NEW_FOLDER_NAME>

To change application URI :

/usr/bin/selectorctl --interpreter=<python|ruby> [--user=USER] [--print-summary] [--json] --transit-webapp <FOLDER_NAME> <NEW_URI>

To change application interpreter version:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --set-user-current --version=<NEW VERSION> <FOLDER_NAME>

To set application WSGI handler ( Python only):

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --setup-wsgi=<file_path:callable> <FOLDER_NAME>

To install modules to application environment:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --enable-user-extensions=<module1[,module2...]> <FOLDER_NAME>

To remove modules from application environment:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --disable-user-extensions=<module1[,module2...]> <FOLDER_NAME>

To list modules installed in application environment:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--print-summary] [--json] --list-user-extensions <FOLDER_NAME>

To print applications summary for a user:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--json] --user-summary

To list available interpreters:

/usr/bin/selectorctl --interpreter=python [--user=USER] [--json] --list

Hide Python Selector Icon

It is possible to hide or show Python Selector icons by marking or unmarking proper checkbox in LVE Manager Options tab.

The same result can be accomplished in CLI by running:

cloudlinux-config set --json --data '{"options":{"uiSettings":{"hideRubyApp":false, "hidePythonApp":false}}}'

Note

If you are using cPanel/WHM, you can also configure hide/show CloudLinux Python Selectors in WHM | Feature Manager. For that, you’d need to first uncheck Hide Python App in web-interface in the LVE Manager. This will make the menu appear for all accounts. After that, you are free to disable this app in WHM | Feature Manager for the required feature lists.

Python Selector (Beta)

Note

This documentation is for the new version of Python Selector beta. You can find documentation for the old Python Selector here

Overview and Requirements

Python Selector is a CloudLinux component that allows each user to easily deploy and manage Python applications via application server.

Requirements

Important!

Do not downgrade LVE Manager to versions lower than 4.2.2 if you have already migrated Python applications because it will break migrated applications.

  • Python Selector supports the following Alt-Python versions:
    • alt-python27 2.7.16, supported by CloudLinux 6, CloudLinux 7
    • alt-python33 3.3.7, supported by CloudLinux 6, CloudLinux 7
    • alt-python34 3.4.9, supported by CloudLinux 6, CloudLinux 7
    • alt-python35 3.5.6, supported by CloudLinux 6, CloudLinux 7
    • alt-python36-3.6.8, supported by CloudLinux 6, CloudLinux 7
    • alt-python36-3.7.2, supported by CloudLinux 6, CloudLinux 7
  • This feature is available for CloudLinux 7, CloudLinux 6 hybrid and CloudLinux 6.
  • New Python Selector requires LVE Manager version 4.2 or later.
  • It supports cPanel and DirectAdmin servers. On DirectAdmin only on Apache. Plesk will not be supported.
  • Python Selector uses mod_passenger to host Python. For more details about mod_passenger, please read documentation.
  • Python Selector works with EasyApache 3 (note EOL at 1st September 2019), EasyApache 4 and LiteSpeed Web Server. Or Apache on DirectAdmin.

Migration to the new Python Selector

The new Python Selector has a bunch of new features:

  • the ability to set environment variables for the application
  • the ability to set dependencies from the file requirements
  • the ability to start and stop applications as in Node.js Selector
  • the ability to add and edit custom configurations
  • the ability to install modules from the custom configurations

All existing Python applications (created before the update of LVE Manager to version 5.0.1-1) will work the same as before. You do not need to migrate them unless you’d like to use new features. These applications we define as old applications.

Important!

There are some risks during the migration process and the migration can fail. To avoid such issues and make it possible to solve them if any, only user who created a particular application is allowed to initiate the migration process.

You do not need to migrate the new applications that will be created after the update to the LVE Manager 5.0.1-1. All new features are available for them.

Important!

You cannot migrate back to the old application. If you face any issue during the migration, please contact our support team.

How to migrate an application to the new Python Selector

Note

Only user who created an application can migrate it.

To migrate a Python application:

  • Log in to your control panel.
  • Open Python Selector user interface.
  • Choose an application to migrate and click in the Actions section. You will see the popup.
  • Click Migrate in the popup.
  • After successful migration, you will see the confirmation popup.

If you face any issue during the migration, please contact our support team.

Installation

New clients can install Python Selector using the CloudLinux Installation Wizard.

cPanel

To use Python Selector, it is required to install the following:

  • alternative Python packages by running the following command:

    yum groupinstall alt-python
    
  • LVE Manager, LVE Utils and Phusion Passenger to create isolated Python environments by running the following command:

    yum install lvemanager lve-utils alt-python-virtualenv ea-apache24-mod-alt-passenger
    

For EasyApache 3:

yum install lve-utils lvemanager alt-python-virtualenv alt-mod-passenger

DirectAdmin

To use Python Selector, it is required to install the following:

  • alternative Python packages by running the following command:

    yum groupinstall alt-python
    
  • LVE Manager, LVE Utils and Phusion Passenger to create isolated Python environments by running the following command:

    yum install lve-utils lvemanager alt-python-virtualenv alt-mod-passenger
    
  • CageFS for better security. See CageFS documentation for details.

Note

After installation, please make sure that you have unmarked appropriate checkboxes in LVE Manager Options tab to show Python App in the web-interface.

Note

Adding Python module requires executing permissions to gcc/make binaries. Please enable compilers in Compiler Access section of WHM, then run:

cagefsctl --force-update

Command Line Interface

Below, there is a list of commands hoster and end user can run in a command line.

Hoster

Note

When running user command as root, please use --user option.

  • Get all Python-related information: default version, a list of supported versions, status of Python Selector, a list of users, their applications, etc:

    cloudlinux-selector [get] [--json] --interpreter python
    

    JSON output for get command:

{
  "selector_enabled": true | false, 
  "default_version": "2.7.15", 
  "result": "success", 
  "timestamp": 1508667174.220027,
  “cache_status”: “ready”,         //  or “updating” during automatic yum cache rebuild
  "available_versions": {   //  begin of  “versions”
      "2.7.15" : {   //   begin of version "2.7.15"
          "status": "enabled",  //  enabled, disabled, not_installed, installing, removing, locked
          “base_dir”: “/opt/alt/alt-python27”   //  empty when version is not installed
          “users”: {   //  begin of  “users”
              “user1”: {   //  begin of “user1”
	“homedir”: “/home/user1”,		
                 “applications”: {    //  begin of “applications”
                     “apps_dir/app1” : {   //   begin of application “apps_dir/app1”
                         “domain”: “cltest1.com”,
                         “app_uri”: “apps/my-app1”,
                         “startup_file” : “run.py”,
                         “entry_point” : “app”,
                         “app_status” : “started”,   // ‘started’ or ‘stopped’
                         “config_files” : [
                             “requirements.txt”,
                             “requirements-migration.txt”
                         ],
                         “env_vars” : {
                             “var1” : “value1”,
                             “var2” : “value2”
                         },
                     },   // end of application “apps_dir/app1”
                     “apps_dir/app2” : {    //   begin of application “apps_dir/app2”
                          << data for application “apps_dir/app2”  (same structure as for application “apps_dir/app1” above) >>
                     },   //  end of application “apps_dir/app2”
                 },   //  end of “applications”
              },   //  end of “user1”
              “user2”: {   //  begin of “user2”
                  << data for user “user2”  (same structure as for “user1” above) >>
              },   //  end of “user2”
          },   // end of “users”
        },    //  end of version “2.7.15”
      "8.21.5" : {   //   begin of version "3.3.7"
            << data for version "3.3.7"  (same structure as for version “2.7.15” above) >>
        },    //  end of version “3.3.7”
    },    //  end of “versions”
}   //   end of json
  • Set default version, supported versions, and status of Python Selector:

    cloudlinux-selector set [--json] --interpreter python (--selector-status <enabled,disabled> | --default-version <str> | --supported-versions <str>)
    

Examples

  1. Enable Python Selector:

    cloudlinux-selector set --json --interpreter python --selector-status enabled
    
  2. Set default Python Selector version as 3.3:

    cloudlinux-selector set --json --interpreter python --default-version 3.3
    
  3. Set supported Python Selector version as 3.3:

    cloudlinux-selector set --json --interpreter python --supported-versions='{"2.7": false, "3.3": true}'
    
  4. Install a specific Python version:

    cloudlinux-selector install-version --json --interpreter python --version 2.7
    
  5. Uninstall a specific Python version:

    cloudlinux-selector uninstall-version --json --interpreter python --version 2.7
    
  6. Enable a specific Python version:

    cloudlinux-selector enable-version --json --interpreter python --version 2.7
    
  7. Disable a specific Python version:

    cloudlinux-selector disable-version --json --interpreter python --version 2.7
    
  • Change version for an application:
    • For a specific application:

      cloudlinux-selector set [--json] --interpreter python --user <str> --app-root <str> --new-version <str>
      
    • For all applications that use specific Python version:

      cloudlinux-selector change-version-multiple --json --interpreter python --from-version <str> --new-version <str>
      
    • For multiple applications:

      cloudlinux-selector change-version-multiple --json --interpreter python --data  <pairs user:app-root as json> --new-version <str>
      

Examples

  1. Change version for a specific application:

    cloudlinux-selector set --json --interpreter python --user user1 --app-root apps_dir/app1 --new-version 2.7
    
  2. Change version for all applications that use version 2.7.15 to version 3.3.5:

    cloudlinux-selector change-version-multiple --json --interpreter python --from-version 2.7 --new-version 3.3
    
  3. Change version of multiple application(s) and/or multiple users:

    cloudlinux-selector change-version-multiple --json --interpreter python --data <pairs user:app-root as json> --new-version <str>
    

Example

cloudlinux-selector change-version-multiple --json --interpreter python --data [ {“user”: “user1”, “app_root”: “apps/app1”}, {“user”: “user2”, “app_root”: “apps/app1”} ]  --new-version 2.7

Common output for all set commands:

in case of success:

{
  "result": "success", 
  "timestamp": 1508666792.863358
}

in case of error:

{
  "result": "Some error message",
  "details" : "Traceback: ..." ,
  "context": {},
  "timestamp": 1508666792.863358
}

in case of warning:

{
  "result": "success",
  "warning" : "Some warning message" ,
  "context": {},
  "timestamp": 1508666792.863358
}

End User

Note

To start all users CLI commands use cagefs_enter command:

/bin/cagefs_enter.proxied /usr/sbin/cloudlinux-selector --json <other parameters>
  • Get config file for the user application:

    cloudlinux-selector read-config [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str> --config-file <name>
    

    JSON output:

    {
      	"result": "success", 
     "timestamp": 1508666792.863358
     	 “data”: “content of config file as Base64 encoded string”
    }
    

    Example:

    cloudlinux-selector read-config --json --interpreter python  --user user1 --app-root app_dir/app1 --config-file requirements.txt
    
  • Save config file for user application:

    cloudlinux-selector save-config [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str> --config-file <path> --content <content of config file as Base64 encoded string>
    

    JSON output (the same as for all set commands):

    {
      	"result": "success", 
    "timestamp": 1508666792.863358
    }
    

    Example:

    cloudlinux-selector save-config --json --interpreter python  --user user1 --app-root app_dir/app1 --config-file requirements.txt  --content VGh1ICAyIE5vdiAxMDo0MzoxMiBFRFQgMjAxNwo=
    

    Note

    An output for all commands below is like in Hoster’s CLI, but filtered out by username.

  • Get a list of applications for a specific user:

    cloudlinux-selector [get] [--json] --interpreter python  [--user <str> | --domain <str>]
    

    Example:

    cloudlinux-selector get --json --interpreter python  --user user1
    
  • Create user application:

    cloudlinux-selector create [--json] --interpreter python  [--user <str> | --domain <str>]  --app-root <str> --app-uri <str> [--version <str>]  [--startup-file <str>] [--entry-point <str>] [--env-vars <json string>]
    

    Example:

    cloudlinux-selector create --json --interpreter python --app-root my_apps/app1 --domain xyz.com --app-uri apps/app1 --version 2.7 --startup-file run.py --entry-point app
    
  • Start, restart, stop, and destroy user application:

    cloudlinux-selector (start | restart | stop | destroy) [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str>
    

    Example:

    cloudlinux-selector start --json --interpreter python --user user1 --app-root my_apps/app1
    
  • Change properties for an application:

    cloudlinux-selector set [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str> [--app-mode <str>]  [--new-app-root <str>]  [--new-domain <str>]  [--new-app-uri <str>]  [--new-version <str>]  [--startup-file <str>] [--entry-point <str>] [--env-vars <json string>] [--config-files <str>]
    

    Example:

    cloudlinux-selector set --json --interpreter python  --user user1 --app-root my_apps/app1 --app-mode production  --new-app-root new_apps/new_app1  --new-domain new.xyz.com --new-app-uri new_apps/app1  --new-version 8  --startup-file new_app.js --env-vars { “var1” : “value1”, “var2” : “value2” }  --config-files requirements.txt,reqs.txt
    
  • Run PIP install for user application:

    cloudlinux-selector install-modules [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str> --requirements-file <path>
    

    Example:

    cloudlinux-selector install-modules --json --interpreter python --user user1 --app-root my_apps/app --requirements-file requirements.txt
    
  • Optional: install or uninstall Python packages for user application:

    cloudlinux-selector (install-modules|uninstall-modules) [--json] --interpreter python  [--user <str> | --domain <str>] --app-root <str> --modules <module1[,module2...]>
    

    Example:

    cloudlinux-selector install-modules --json --interpreter python --user user1 --app-root my_apps/app --modules json-annotate,termcolor
    
  • Optional: run Python script in virtual environment of user application, arguments <args> are passed to the script:

    cloudlinux-selector run-script [--json] --interpreter python  [--user <str | --domain <str>>] --app-root <str> --script-name <str> [-- <args>...]
    

    Example:

    cloudlinux-selector run-script --json --interpreter python --user user1 --app-root my_apps/app --script-name test_script -- --script_opt1 --script_opt2 script_arg1 script_arg2
    

    JSON output:

    {
      	"result": "success", 
     	"timestamp": 1508666792.863358
       	“data”: “script output as Base64 encoded string”
    }
    

User Interface

Hoster

Hoster interface allows to enable and disable Python Selector and manage individual Python versions.

Go to LVE Manager → Options Tab → Python Selector.

A list of installed Python versions is displayed. There are several columns in the list.

  • Version — displays Python version.
  • Path — Python package location.
  • Applications — number of applications that use this Python version. Click on an application number to go to the list of applications.
  • Enabled — displays if particular Python version is enabled.
  • Actions — allows to install, delete, and make default a particular Python version.

To display all changes immediately click Refresh.

How to enable/disable Python Selector

To enable Python Selector move a slider to Enable and complete the action by clicking Agree or click Cancel to close the popup. To disable Python Selector move a slider back to Disable.

Note

If you disable Python, all users won't be able to manage their applications

Note

Python Selector icon in end user interface is absent when Python is disabled.

How to manage Python Selector

In the list of installed Python versions you can enable and disable, install and delete, and set a particular Python version as a default.

Enable and disable particular Python version

To enable particular Python version do the following:

  • Move a disabled slider in the Enabled column for a particular Python version.
  • In the confirmation popup click Agree to save changes or Cancel to close popup.

To disable particular Python version do the following:

  • Move an enabled slider in the Enabled column for a particular Python version.
  • In the confirmation popup click Agree to save changes or Cancel to close popup.

Install and delete particular Python version

To install particular Python version do the following:

  • Click Install button in the Actions column for a particular Python version.
  • In the confirmation popup click Agree to save changes or Cancel to close popup.

To delete particular Python version do the following:

  • Click Bin icon in the Actions column for a particular Python version.
  • In the confirmation popup click Agree to start uninstalling process. Or close popup without changes by clicking Cancel button.

Note

It is impossible:

  • to remove default Python version
  • to remove version with applications
  • to install or remove version if another installation/uninstalling process is running

Make a particular Python version as a default

To make a particular Python version as a default do the following:

  • Click Double-Tick icon in the Actions column for a particular Python version.
  • In the confirmation popup click Agree to save changes or Cancel to close popup.

Note

It is impossible to make default disabled version

Applications column

To view and operate with the list of domains with Python versions click a number in the Applications column for a particular Python version. A section with a list of Domains for particular Python version will be displayed.

Domains are displayed by three. To load more domains click Load More button.

To change Python version for a particular application do the following:

  • Click Double-Arrow icon in the Actions column in a particular application row. A confirmation popup will be displayed.
  • In the popup choose Python version from a dropdown.
  • Click Change to confirm the action or Cancel to close the popup.
  • To refresh state of applications in current version you can click Refresh.

Note

All packages of the application(s) will be re-installed.

End User

Note

Python Selector icon in end user interface is absent when Python is disabled

End User interface allows end users to setup and manage Python for their web applications.

Go to cPanel → Software Section → Setup Python App.

Web Applications page is displayed.

There are several columns in the list:

  • App URI — application URI including the domain.
  • App Root Directory — application root directory relative to user's home.
  • Status — started/stopped — displays if an application is running or not and version of the application.
  • Actions — allows to migrate, start, restart, stop, edit, and remove a particular application.

How to manage an application

Create application

  1. Click Create Application to create an application. The Create Application tab opens.

  2. Specify the following:

    • Python version — select from the dropdown (required);
    • Application root — physical address to your application on a server that corresponds with its URI (required);
    • Application URL — HTTP/HTTPS link to your application (optional);
    • Application startup file — the file where WSGI callable object is located. It is required for application to run. Default is passenger_wsgi.py;
    • Application Entry point — WSGI callable object for your application (optional). Default is application;
  3. Optionally, add environment variable. To do so, click Add Variable and specify variable name and value, then click the Done or Cancel to close an adding form.

To delete or edit environment variable, click Bin or Pencil for the required variable.

Start application

To start a stopped application do the following:

  • Click Start in the Actions column in a stopped application row.
  • When an action is completed a Start changes to Stop.

Stop application

To stop a started application do the following:

  • Click Stop icon in the Actions column in a started application row.
  • When an action is completed a Stop changes to Start.

Restart application

To restart a started application do the following:

  • Click Restart in the Actions column in a started application row. A current row is blocked and when a process is completed it will be unblocked.

Remove application

To remove application do the following:

  • Click Bin in the Actions column in a particular application row.
  • In the confirmation popup click Agree to start removing or Cancel to close the popup.
  • When an action is completed an application will be removed from the Web Applications table and a confirmation popup will be displayed.

Edit application

To edit application do the following:

  • Click the Pencil in the Actions column in a particular application row. A particular application tab opens.

The following actions are available:

  • Restart application — click Restart.
  • Stop application — click Stop App.
  • Remove application — click Destroy and confirm the action in a popup.
  • Change Python version — choose Python version from a dropdown.
  • Change Application root — specify in a field a physical address to the application on a server that corresponds with its URI.
  • Change Application URL — specify in a field an HTTP/HTTPS link to the application.
  • Open Application URL — click the Open.
  • Change Application startup file — specify as NAME.py file.
  • Change Application Entry point — specify WSGI callable object for your application.
  • Run pip install command — click Run pip install to install the package(s) described in the configuration file.
  • Add Configuration files — click Add and specify all required information.
  • Edit available configuration file — click Edit, the file opens in a new popup.
  • Remove available configuration file from the list — click Remove and confirm the action or click Cancel to close the popup.
  • Add Environment variables — click Add Variable and specify a name and a value.

Click Save to save all changes or Cancel to close the tab.

Migrate application

For details see How to migrate an application to the new Python Selector

Deploying Trac using Python Selector

  1. In Setup Python App create an application. Trac project WSGI script will be located in App Directory (e.g. trac).

App URI – is a URL where web-interface is located (e.g. Trac – web-interface is located in YOUR_DOMAIN/trac).

Trac needs Python version from 2.5 to 3.0, in the actual example version 2.7 is used.

  1. When the App is created, add the following modules: Trac, Genshi, MySQL-python.

2.1. Alternatively, connect to the server via SSH and perform the following steps:

source ~/virtualenv/trac/2.7/bin/activate

then:

~/virtualenv/trac/2.7/bin/easy_install Trac mysql-python (using easy_install)

or

~/virtualenv/trac/2.7/bin/pip install trac mysql-python

(using pip).

  1. In cPanel create MySQL database and a user. Add user to database.

In this example DB tractest_trac and user tractest_trac were created.

  1. Connect to the server via SSH using your cPanel account.

Create Trac project:

~/virtualenv/trac/2.7/bin/trac-admin
~/trac_project initenv

For the Database connection string parameter enter the following: mysql://user:password@localhost/database_name – here the data for connecting MySQL database are specified.

Note

In case of ... The charset and collation of database are 'latin1' and 'latin1_swedish_ci' error the database must be created with one of (('utf8', 'utf8_bin'), ('utf8mb4', 'utf8mb4_bin')) ... while creating the project, you should change database encoding.

To change encoding, in cPanel run phpMyAdmin, choose DB, go to Operations, choose the necessary encoding in Collation section and click Go.

After that you have to repeat the procedure of creating a project. When done, the Trac project must appear: ~/trac_project

  1. To create project frontend run the following:
~/virtualenv/trac/2.7/bin/trac-admin ~/track_project deploy ~/trac

~/track_project — is the path to the project, ~/trac — is the path, that was specified while setting App Directory.

Create topic directory by default:

cd ~/public_html/trac
mkdir chrome 
cp -R ~/trac/htdocs/ ~/public_html/trac/chrome/

All project static files are located in this directory; the changes can be added here as well.

  1. To add path to WSGI file in the created application:

Go back to cPanel Setup Python App, change WSGI file location for your application to cgi-bin/trac.wsgi, click Update to apply changes and then click Restart.

Your existing application now must look like the following:

  1. Adding authorization:

In ~/public_html/trac/.htaccess after CLOUDLINUX PASSENGER CONFIGURATION section add the following lines:

AuthType Basic
AuthName "trac"
AuthUserFile /home/tractest/trac/passwd
Require valid-user
  1. Add new user and create password file /usr/local/apache/bin/htpasswd with ~/trac/passwd admin.

Enter password.

~/virtualenv/trac/2.7/bin/trac-admin  ~/track_project permission add admin TRAC_ADMIN

Add admin user to TRAC_ADMIN group.

Here the path trac directory is equal to App Directory in your project.

Now Trac is available via YOUR_DOMAIN/trac.

Trac with MySQL

To use Trac with MySQL database you should install alt-python27-devel package.

To install run:

yum install alt-python27-devel --enablerepo=cloudlinux-updates-testing 

EasyApache 4

CloudLinux has Python Selector, which allows creating applications with ea-apache24-mod-alt-passenger. However, it does not allow using cPanel application manager.

It is not correct to install both of those packages on the server because they contain the same passenger module for Apache web server.

The new ea-ruby24-mod_passenger is available for download from our updates-testing (beta) repository which allows you to run applications via cPanel application manager and CloudLinux Python Selector.

To install run:

# yum install lvemanager alt-python-virtualenv
# yum install ea-ruby24-mod_passenger --enablerepo=cl-ea4-testing