How to deploy Python Scripts to bereveal.com
Published: 2022-02-12 12:57:49

<b>How to deploy Python to bereveal.com.</b>

<p> Here is a tutorial on how to deploy a Django project. You can also use other Python frameworks in the same way.</p>

<p>Currently they have two packages for Python on their site. Buy any one from here.</p>

<blockquote>
  1. <a href="https://bereveal.com/django-hosting-basic.html" target="_blank">Django Hosting Basic</a><br>

  2. <a href="https://bereveal.com/linux-website-hosting/premier/" target="_blank">Premier Web hosting plan</a><br>
                  3. <a href="https://bereveal.com/linux-website-hosting/value/" target="_blank">Value Web hosting plan</a><br>
                  4. <a href="https://bereveal.com/linux-website-hosting/advanced/" target="_blank">Advanced Web hosting plan</a><br>
                  5. <a href="https://bereveal.com/linux-website-hosting/basic/" target="_blank">Basic Web hosting plan</a><br>
</blockquote>

<p>Needless to say, all of plans are suitable for Python hosting. But SSH is automatically unlocked when you buy the plan mentioned for Python, but you have to buy SSH separately in other plans.</p>

<p>SSH remains locked during the trial period. So you have to buy SSH separately during the trial period. You can also buy for a month if you want.</p>


<div class="row">
			<div class="columns">
				<p> They says, Following the feedback of web developers, we’ve added a new functionality to the Advanced section of the&nbsp;Control Panel&nbsp;- the Python Settings.</p>
<p>The new Python <span style="line-height: 20.8px;">Settings</span> will allow you to edit the current Python version and to enable Python-compatible applications for your projects.</p>
<p>Located right next to PHP Settings, it gives you one-click access to various Python management options.</p>
<h2>What is Python about?</h2>
<p><a href="https://www.python.org/" target="_blank">Python</a> is one of the most important application development languages and has been around for a long time now.</p>
<p>Its standard library supports many Internet protocols, including JSON, FTP, IMAP, HTML and XML.</p>
<p>There are different types of Python-based software:</p>
<p>for web development purposes:</p>
<ul style="list-style-type: circle;">
<li>frameworks such as Django and <a href="http://www.pylonsproject.org/" target="_blank">Pyramid</a>; micro-frameworks such as Flask and Bottle;</li>
<li>advanced content management systems such as Plone and django CMS;</li>
<li>asynchronous networking libraries like <a href="http://www.tornadoweb.org/en/stable/" target="_blank">Tornado</a>, which is perfect for long polling, WebSockets and other applications that require a long-lived connection to each user;</li>
<li>full-stack frameworks (like web2py) for rapid development of fast and portable web-based, database-driven apps;</li>
</ul>
<p>for scientific and numerical computing purposes:</p>
<ul>
<li>open-source packages like <a href="http://www.scipy.org/" target="_blank">SciPy</a>, Matplotlib and NumPy, which are used in mathematics, science and engineering;</li>
<li><a href="http://pandas.pydata.org/" target="_blank">Pandas</a> - a BSD-licensed library for high-performance data analysis and modeling;&nbsp;</li>
<li><a href="http://ipython.org/" target="_blank">iPython</a> - a powerful command shell for easier editing and recording of work sessions that supports interactive data visualization and parallel computing;</li>
<li>Software Carpentry Course, which teaches the basics of scientific computing and provides open-access teaching materials;</li>
</ul>
<p>for software development purposes:</p>
<ul style="list-style-type: circle;">
<li><a href="http://buildbot.net/" target="_blank">Buildbot</a> and Apache Gump, which are used for automating software build, test and release processes;</li>
<li>Roundup and Trac - issue tracking and project management tools;</li>
</ul>
<p>for system administration purposes:</p>
<ul style="list-style-type: circle;">
<li><a href="https://www.ansible.com/" target="_blank">Ansible</a> - an easy-to-deploy IT automation engine that automates configuration management, application deployment and cloud provisioning;</li>
<li><a href="https://saltstack.com/" target="_blank">Salt</a> - a powerful open-source platform for IT automation and orchestration;</li>
<li><a href="https://www.openstack.org/" target="_blank">OpenStack</a> - a high-performance computing, storage and networking platform;</li>
</ul>
<p>Python is easy to learn and use, no matter if you're new to programming or an experienced developer.</p>
<p>It is backed up by a large community, which <a href="https://www.python.org/community/workshops/" target="_blank">organizes conferences and workshops</a>, collaborates on code development projects, supports <a href="http://docs.python.org/" target="_blank">an extensive Python documentation</a> to help newbies along the way and maintains mailing lists to keep users up to date.</p>
<h2>How do I use the Python Manager?</h2>
<p><img src="https://images.cloudlogin.co/imgs/python-settings-control-panel.png" alt=""></p>
<p>From the Python Manager section of the Control Panel, you’ll be able to set the Python version for your account.</p>
<p>You can choose between Python 2.7, Python 3.1 and the latest version - Python 3.5.</p>
<p><img src="https://images.cloudlogin.co/imgs/python-settings-change-version.png" alt=""></p>
<h2>How to install a Python-based CMS on our platform (tutorial)?</h2>
<p>To give you a better idea of how Python-based applications work on our servers, we’ll show you how to install the Django framework-powered <a href="http://mezzanine.jupo.org/" target="_blank">Mezzanine CMS</a> on our platform via SSH.</p>
<p><strong>Step 1:</strong> Create a virtual environment&nbsp;(venv) in the root folder of your account, in our case:</p>
<pre style="position: relative;"><code>/usr/local/python-3.5/bin/virtualenv /home/venv/</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 2:</strong> Enter the newly created virtual environment using the following command:</p>
<pre style="position: relative;"><code>source /home/venv/bin/activate</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 3:</strong> Go to the "www"&nbsp;folder of your hosting account:</p>
<pre style="position: relative;"><code>cd /home/www/</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 4:</strong> Install the Mezzanine CMS binaries along with the corresponding modules fastcgi support and flup6.</p>
<pre style="position: relative;"><code>pip install git+https://github.com/NetAngels/django-fastcgi
pip install flup6
pip install mezzanine</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p class="info"><strong>NOTE:</strong> Make sure you disable the “Outgoing Connections” option or the installation of the modules will fail.</p>
<p><strong>Step 5:</strong> Set up the Mezzanine project In a selected custom directory, in our case mydjangocms:</p>
<pre style="position: relative;"><code>mezzanine-project mydjangocms</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 6:</strong> Create a domain or subdomain for the newly installed CMS.</p>
<p>Keep in mind that the Jail host option needs to be deactivated in order for the installed modules to function properly.</p>
<p>Point your newly created domain or subdomain to the path of your project. In our example, the path is "/www/mydjangocms".</p>
<p><img src="https://images.cloudlogin.co/imgs/python-settings-tutorial.jpg" alt=""></p>
<p><strong>Step 7:</strong> Go to the newly created Mezzanine CMS folder:</p>
<pre style="position: relative;"><code>cd mydjangocms</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 8:</strong> Set up a database for your CMS. In our case, we’ll use the sqlite3 database for the sake of ease (alternatively, you could set up a MySQL/PostgreSQL database by applying the necessary settings to the Python setup file:</p>
<pre style="position: relative;"><code>python manage.py createdb</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p>You will see the following message:</p>
<pre style="position: relative;"><tt>A site record is required.
Please enter the domain and optional port
in the format 'domain:port'. For example 'localhost:8000' or 'www.example.com'.
</tt>
<span style="font-family: sans-serif, Arial, Verdana, 'Trebuchet MS'; line-height: 1.6;">Hit enter to use the default (127.0.0.1:8000):

Use the default option for the SQL host. You will then be asked to enter your username, email and password. 
These are the login credentials for the CMS system and not the database. 
</span><span style="font-family: sans-serif, Arial, Verdana, 'Trebuchet MS'; line-height: 1.6;">In the end, you can choose if you want to have some demo content inserted.</span><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 9:</strong> Set up an .htaccess file in the folder of your project with the following entries:</p>
<pre style="position: relative;"><code>RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.fcgi/$1 [QSA,L]</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 10:</strong> Set up an index.fcgi file in the folder of your project using the following code&nbsp;(it will serve as an entry point for all requests to the CMS).</p>
<p>Don't forget to replace "<em>mydjangocms</em>" with the name of your project.</p>
<pre style="position: relative;"><code>#!/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)
# Set the DJANGO_SETTINGS_MODULE environment variable.
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)</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 11:</strong> You'll need to make the index.fcgi file executable using this command:</p>
<pre style="position: relative;"><code>chmod +x index.fcgi</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 12:</strong> Edit the settings file located inside "mydjangocms/local_settings.py" and replace</p>
<pre style="position: relative;"><code>ALLOWED_HOSTS = []</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p>With your actual host name:</p>
<pre style="position: relative;"><code>ALLOWED_HOSTS = ['mydjangocms.my-best-domain.net']</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p><strong>Step 13:</strong> Run the following command to collate the static files:</p>
<pre style="position: relative;"><code>python manage.py collectstatic</code><div class="open_grepper_editor" title="Edit &amp; Save To Grepper"></div></pre>
<p>You are now ready and your site should be up and running.</p>
<p>In our example, the newly installed Mezzanine CMS will resolve to:</p>
<p><a href="http://mydjangocms.my-best-domain.net/" target="_blank">http://mydjangocms.my-best-domain.net/</a></p>
<p style="text-align: center;"><a rel="attachment wp-att-12245" href="https://blog.resellerspanel.com/wp-content/uploads/2016/11/django-cms-mezzanine-insllation-complete.jpg"><img class="aligncenter wp-image-12245" src="https://blog.resellerspanel.com/wp-content/uploads/2016/11/django-cms-mezzanine-insllation-complete.jpg" alt="Django CMS Mezzanine - insllation complete" width="680" height="311"></a></p>
<p class="p1">Now you can log into your Mezzanine CMS Admin Panel using the login details set&nbsp;in step 8 above and kickstart&nbsp;a new blog, for example:</p>
<p style="text-align: center;"><a rel="attachment wp-att-12247" href="https://blog.resellerspanel.com/wp-content/uploads/2016/11/django-cms-mezzanine-admin-panel.jpg"><img class="aligncenter wp-image-12247" src="https://blog.resellerspanel.com/wp-content/uploads/2016/11/django-cms-mezzanine-admin-panel.jpg" alt="Django CMS Mezzanine - Admin Panel" width="680" height="287"></a></p>			</div>
		</div>