The Control Panel now features a newly introduced Python Manager

Responding to input from web developers, we have introduced a new feature within the Advanced section of the Hepsia Control Panel – the Python Manager.

This innovative Python Manager enables users to modify the existing Python version and activate Python-compatible applications for their projects. Located adjacent to PHP Settings, it provides convenient one-click access to a range of Python management choices.

About Python

Python stands as a significant programming language for application development, having a substantial history.

Its standard library encompasses support for numerous Internet protocols including JSON, FTP, IMAP, HTML, and XML.

Python-based software encompasses various categories:

For web development:

  • Frameworks such as Django and Pyramid, along with micro-frameworks like Flask and Bottle.
  • Advanced content management systems like Plone and django CMS.
  • Asynchronous networking libraries such as Tornado, beneficial for long polling, WebSockets, and other applications requiring persistent connections.
  • Full-stack frameworks like web2py, designed for swift and portable web-based, database-driven applications.

For scientific and numerical computing:

Open-source packages like SciPy, Matplotlib, and NumPy, integral to mathematics, science, and engineering.

  • Pandas – a BSD-licensed library for high-performance data analysis and modeling.
  • iPython – a potent command shell facilitating easier work session editing and recording, featuring interactive data visualization and parallel computing.
  • Software Carpentry Course – a resource teaching scientific computing fundamentals with open-access teaching materials.

For software development:

  • Buildbot and Apache Gump – tools for automating software build, test, and release processes.
  • Roundup and Trac – tools for issue tracking and project management.

For system administration:

  • Ansible – a user-friendly IT automation engine automating configuration management, application deployment, and cloud provisioning.
  • Salt – a robust open-source platform for IT automation and orchestration.
  • OpenStack – a platform for high-performance computing, storage, and networking.

Python offers an accessible learning curve for both newcomers and experienced developers. It boasts a vibrant community that arranges conferences, collaborates on code development projects, maintains extensive documentation for newcomers, and keeps users informed through mailing lists.

How can I utilize the Python Manager?

Within the Control Panel’s Python Manager section, you have the capability to designate the Python version for your account. You’re presented with options including Python 2.7, Python 3.1, and the most recent release, Python 3.5.

How to Install a Python-Based CMS on Our Platform (Tutorial):

To provide you with a clearer understanding of how Python-based applications operate on our servers, we will guide you through the process of installing the Mezzanine CMS, powered by the Django framework, on our platform via SSH.

Step 1: Establish a Virtual Environment (venv) within the root folder of your account, as follows:

/usr/local/python-3.5/bin/virtualenv /home/venv/

Step 2: Access the newly created virtual environment using the command:

source /home/venv/bin/activate

Step 3: Navigate to the “www” folder of your hosting account:

cd /home/www/

Step 4: Install the Mezzanine CMS binaries alongside the associated modules for fastcgi support and flup6:

pip install git+https://github.com/NetAngels/django-fastcgi
pip install flup6
pip install mezzanine

Note: Ensure to deactivate the “Outgoing Connections” option to prevent module installation failure.

Step 5: Set up the Mezzanine project within a custom directory, such as “mydjangocms”:

mezzanine-project mydjangocms

Step 6: Create a domain or subdomain for the installed CMS. Remember to deactivate the Jail Host option for proper module functionality.

Point the newly created domain or subdomain to your project’s path, which in our case is “/www/mydjangocms”.

Step 7: Access the newly established Mezzanine CMS folder:

cd mydjangocms

Step 8: Configure a database for your CMS. In this example, we’ll use the sqlite3 database for simplicity. Alternatively, you could set up a MySQL/PostgreSQL database by adjusting the necessary settings in the Python setup file:

python manage.py createdb

You’ll be prompted to provide domain and port information. Use the default option for SQL host, then enter your username, email, and password. These credentials are for the CMS system, not the database. Additionally, choose whether to insert demo content.

Step 9: Create an .htaccess file within your project’s folder with the following content:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.fcgi/$1 [QSA,L]

Step 10: Generate an index.fcgi file within your project’s folder using the provided code. Replace “mydjangocms” with your project’s name:

#!/home/venv/bin/python3.5
# -*- coding: utf-8 -*-
import os
import sys
activate_this = '/home/venv/bin/activate_this.py'
exec(open(activate_this).read(), dict(__file__=activate_this))
cms_path = '/home/www/mydjangocms/'
sys.path.insert(0, cms_path)
os.chdir(cms_path)
os.environ['DJANGO_SETTINGS_MODULE'] = "mydjangocms.settings"
from django_fastcgi.servers.fastcgi import runfastcgi
from django.core.servers.basehttp import get_internal_wsgi_application
wsgi_application = get_internal_wsgi_application()
runfastcgi(wsgi_application, method="prefork", daemonize="false", minspare=1, maxspare=1, maxchildren=1)

Step 11: Make the index.fcgi file executable:

chmod +x index.fcgi

Step 12: Edit the settings file located at “mydjangocms/settings.py” and replace:

ALLOWED_HOSTS = []

With your actual host name:

ALLOWED_HOSTS = ['mydjangocms.my-best-domain.net']

Step 13: Execute the following command to gather static files:

python manage.py collectstatic

Your site is now operational. In our example, the Mezzanine CMS can be accessed at:

http://mydjangocms.my-best-domain.net/

You can log into the Mezzanine CMS Admin Panel using the login details set in step 8 and proceed to create new content, such as a blog.

Leave a Reply