Category Archives: Hosting Marketers News

How to run Python scripts

How to run Python scripts

If you wish to run Python scripts in your hosting account, you can create and edit them in two ways: either in cPanel or via SSH.

To create and edit Python script in cPanel use the following steps: 

1. Log in to your cPanel:
2. Go to section Files > File Manager:

3. You can choose whether you want to run the script in the cgi-bin folder or outside of it.

The cgi-bin folder contains executable CGI scripts. If the file should be placed out of the cgi-bin folder, .htaccess should be created additionally.

4. In order to run the Python script in the cgi-bin folder follow the steps:

  • Go to the cgi-bin folder
  • Create a file with a .py extension, for example nctest.py in the /home/cPuser/public_html/cgi-bin directory (where cPuser is your actual cPanel username).

5. In order to create the file, click New File > specify the name of the file with the required extension and click Create New File:

6. Change the permission of the file to 0755

NOTE: Files are created with default permissions 0644. The .py file will become executable when the permissions are changed to 0755.

7. In order to change the permissions of the file you need to select the file > click Change Permissions > Mark Execute for User, Group, World columns and click Change Permissions:

8. Open the file, click Edit and add the code.

We will add the following script for testing purposes:

#!/usr/bin/python

print “Content-type: text/html\n\n”
print “How to run Python scripts in cPanel”

NOTE: The file should start with the path to the Python scripts that is /usr/bin/python on our servers, but you can run the whereis pythoncommand via SSH to check the directory.

Now the script should work using http://domain.com/cgi-bin/nctest.py

If you would like to run the Python file not in the cgi-bin folder (in public_html or any other directory), it is necessary to add the following code to the .htaccess file in the same directory where the Python script is placed:

Options +ExecCGI
AddHandler cgi-script .py 

testing a red5 live streaming rtmp, plus creating a player for the rtmp

We created an app for live streaming here.

Now we going to test it and create a player code so we can start streaming to our site.

Do you have fmle installed on your computer? You need to download it from adobe.

Lets test it first, go to

http://209.95.39.220/test/

enter the rtmp of your app. the rtmp is

rtmp://server IP/app

so:

rtmp://RED5_SERVER_IP/live221

Enter this URL on the long string and click connect, now click “Publish” your camera will start,  and now click “Play” if the 2 players show the same thing you are on. Everything is good.

OK, now we have to work on “stream name”. We talked about rtmp, and we tested it, the testing site if you go back to it

http://209.95.39.220/test/

it has a stream name, “testing” this must be on both the publishing and on the player.

so it must be on the FMLE and on the player code.

fmle

(click on the image to have a better view)

the FMLE on the left you have your settings, frame per second, bitrate, your camera, format.

on the red5 server your bitrate should be about 320kbps higher then that you need a lot of RAM and server resources.

lets configure the fmle as the image shows.

on the right on the FMS URL enter the rtmp and on the stream enter your chosen stream name, in this case I entered “live” see image.

click connect, and then below click “Start”

you now streaming to your server.

 

Now creating a player for this stream. Go to

http://www.hosting-marketers.com/generator/

at the bottom on the “Streamer” enter the rtmp:

rtmp://RED5_SERVER_IP/live221

and on “Stream / File Name” enter the stream name, which we used on the FMLE, “live”

Click  “Generate Code!”

Take the “Preview & Embed” code, paste on your site and that’s it.

You can also use an image on the player, it will show before the user click to play,  enter the image URL on “Overlay Poster”

Node.js some information

As third-party software, Hosting Marketers does not support node.js beyond installation.
All our servers have node.js installed, but you need to configure it on your account, for that we need to know which port you using for the node, and you will need to create cron job and a bash file. The port we need to open it on our server firewall.

Create a file for example server.js on your account. on this file enter the code:

var http = require(“http”);
http.createServer(function(request, response) {
response.writeHead(200, {“Content-Type”: “text/plain”});
response.write(“Hello World”);
response.end();
}).listen(5002);

the number 5002 is your node port, open a ticket and explain that you going to use node and you want port 5002 opened.

Now in case this is your own vps or a dedicated server:
then create a file for example node.sh and on this file enter the below code:

#!/bin/bash
PGREP=”/usr/bin/pgrep”
NODE=”node”
$PGREP ${NODE}
if [ $? -ne 0 ]
then
/usr/local/bin/node /home/cpanel-username/public_html/server.js> /dev/null 2>&1
fi

we are assuming your first file is server.js.

Now create cron job for the node.sh, this file should be on 755 permissions.
the cron can be:

*/10 * * * * sh /home/cpanel-username/public_html/node.sh >/dev/null 2>&1

this will mean the server will check every 10 minutes if the node is working and restart if it goes down.

this can apply to any script which uses node.js

then to test if the system is working call on your browser:

http://domain:5002
the page should load:
Hello World

But if you are on a shared hosting:
You cannot use the node.sh option because when it pgrep it will find that there is other node process going on so it will not start yours. You will have to contact us so that we use the SCREEN option which will leave the process running on background even when we close the cmd window.
so we open cmd and type
screen
/usr/local/bin/node /home/cpanel-username/public_html/server.js
CTRL D + A
this will close the window and the process will continue, to test
http://domain:5002
the page should load:
Hello World

CloudFlare Railgun available Free of Charge for our Customers

CloudFlare Railgun™

As a CloudFlare Optimized Partner, we are thrilled to offer the CloudFlare Railgun™ technology to all our customers for free on Video Three and above hosting plans. Railgun is CloudFlare’s latest performance optimization technology that gives you significant improvements in site load times. To activate Railgun,  first enable CloudFlare for your domain on your cpanel, then open a ticket with our customer support to enable Railgun for your site.

Railgun ensures that the connection between our network and the CloudFlare network is as fast as possible. Railgun achieves a 99.6% compression ratio for previously uncacheable web objects by using techniques similar to those used in the compression of high-quality video. The average website can expect a 1.43x performance increase.

When a request is made to a CloudFlare server for a web page that is not in cache CloudFlare makes an HTTP connection to the origin server to request the page. It’s that HTTP connection that Railgun accelerates and secures.

Even highly dynamic websites change slowly

Railgun works by recognizing that uncacheable web pages do not change very rapidly. For example, during an experiment, the CNN.com homepage HTML was captured once, and then again after 5 minutes and then again after one hour. The page sizes were 92,516, five minutes still 92,516 and one hour later 93,727.

CNN sets the caching on this page to 60 seconds. After one minute, it is necessary to download the entire page again. However, looking inside the page, not much has changed. In fact, the change between versions is on the order of 100s of bytes out of almost 100k.

Experiments at CloudFlare have revealed similar change values across the web. For example, reddit.com changes by about 2.15% over five minutes and 3.16% over an hour. The New York Times home page changes by about 0.6% over five minutes and 3% over an hour. BBC News changes by about 0.4% over five minutes and 2% over an hour.

Although the dynamic web is not cacheable, it is also not changing quickly. That means that from moment to moment there’s only a small change between versions of a page. CloudFlare Railgun uses this fact to achieve very high rates of compression. This is very similar to how video compression looks for changes from frame to frame; Railgun looks for changes on a page from download to download.

Railgun Technology

Railgun consists of two components: the sender and the listener. The sender is installed at every CloudFlare data center around the world. The listener is a software component that Hosting Marketers has installed on our network for customers.

The sender and listener establish a permanent TCP connection that’s secured by TLS. This TCP connection is used for the Railgun protocol. It’s an all binary multiplexing protocol that allows multiple HTTP requests to be run simultaneously and asynchronously across the link. Or in other words, a persistent connection is opened between CloudFlare’s network and ours and eliminates the overhead of TCP.

We have made it simple for our customers to get the benefits of Railgun with one click. For additional information and instructions on how to activate, visit our Railgun Faq’s page.

Hosting Marketers Partners with CloudFlare!

Hosting Marketers,  is excited to announce our partnership with CloudFlare! If you haven’t heard about CloudFlare before,  their value proposition is simple: they’ll make any website twice as fast and protect it from a broad range of web threats.

Today, hundreds of thousands of websites—ranging from individual blogs to e-commerce sites to the websites of Fortune 500 companies to national governments—use CloudFlare to make their sites faster and more secure. They power more than 65 billion monthly page views—more than Amazon, Wikipedia, Twitter, Zynga, AOL, Apple, Bing, eBay, PayPal and Instagram combined—and over 25% of the Internet’s population regularly passes through our network.

Faster web performance

CloudFlare is designed to take a great hosting platform like Hosting Marketers and make it even better.

They run 26 data centers  strategically located around the world. When you sign up for CloudFlare  from your cpanel  they begin routing your traffic to the nearest data center.

cloudfare network of datacenters

 

As your traffic passes through the data centers, they intelligently determine what parts of your website are static versus dynamic. The static portions are cached on they’re servers for a short period of time, typically less than 2 hours before they check to see if they’ve been updated. By automatically moving the static parts of your site closer to your visitors, the overall performance of your site improves significantly.

CloudFlare’s intelligent caching system also means you save bandwidth, which means saving money, and decreases the load on your servers, which means your web application will run faster and more efficiently than ever. On average, CloudFlare customers see a 60% decrease in bandwidth usage, and a 65% in total requests to their servers. The overall effect is that CloudFlare will typically cut the load time for pages on your site by 50% which means higher engagement and happier visitors.

cloudflare-2

 Broad web security

Over the course of 2011, CloudFlare identified a 700% increase in the number of distributed denial of service attacks  (DDoS) they track on the Internet (see the chart below). As attacks like these increase, CloudFlare is stepping up to protect sites.

cloudflare-3

CloudFlare’s security protections offer a broad range of protections  against attacks such as DDoS, hacking or spam submitted to a blog or comment form. What is powerful about their approach is that the system gets smarter the more sites that are part of the CloudFlare community. They analyze the traffic patterns of hundreds of millions of visitors in real time and adapt the security systems to ensure good traffic gets through and bad traffic is stopped.

Signing up

Any website can deploy CloudFlare, regardless of your underlying platform. By integrating closely with Hosting Marketers, we make the process of setting up CloudFlare “1 click easy” through your existing Hosting Marketers customer control panel (cpanel) dashboard. Just look for the CloudFlare icon, choose the domain you want to enable, and click the orange cloud. That’s it!

cpanel cloudflare activation

Attention that video sites are not allowed according to CloudFlare TOS.

If you need help, please contact our customer support.