Knowledgebase : PHP / Programming

We recommended all Node.js applications are created using our Setup Node.js Application interface. If however you need to run Node just as a CLI we offer many versions. The current versions supported and paths are as follows:

  • Node.js 6.x - /opt/alt/alt-nodejs6/root/bin/node
  • Node.js 8.x - /opt/alt/alt-nodejs8/root/bin/node
  • Node.js 9.x - /opt/alt/alt-nodejs9/root/bin/node
  • Node.js 10.x - /opt/alt/alt-nodejs10/root/bin/node
  • Node.js 11.x - /opt/alt/alt-nodejs11/root/bin/node
  • Node.js 12.x - /opt/alt/alt-nodejs12/root/bin/node
  • Node.js 14.x - /opt/alt/alt-nodejs14/root/bin/node
  • Node.js 16.x - /opt/alt/alt-nodejs16/root/bin/node
  • Node.js 18.x - /opt/alt/alt-nodejs18/root/bin/node

The accompanying applications such as npm can also be found in the root/bin path.

We recommended all Python applications are created using our Setup Python Application interface. If however you need to run Python just as a CLI we offer many versions. The current versions supported and paths are as follows:

  • Python 2.7.x - /opt/alt/python27/bin/python2
  • Python 3.3.x - /opt/alt/python33/bin/python3
  • Python 3.4.x - /opt/alt/python34/bin/python3
  • Python 3.5.x - /opt/alt/python35/bin/python3
  • Python 3.6.x - /opt/alt/python36/bin/python3
  • Python 3.7.x - /opt/alt/python37/bin/python3

We recommended all Ruby applications are created using our Setup Ruby Application interface. If however you need to run Ruby just as a CLI we offer many versions. The current versions supported and paths are as follows:

  • Ruby 1.8.x - /opt/alt/ruby18/bin/ruby
  • Ruby 1.9.x - /opt/alt/ruby19/bin/ruby
  • Ruby 2.0.x - /opt/alt/ruby20/bin/ruby
  • Ruby 2.1.x - /opt/alt/ruby21/bin/ruby
  • Ruby 2.2.x - /opt/alt/ruby22/bin/ruby
  • Ruby 2.3.x - /opt/alt/ruby23/bin/ruby
  • Ruby 2.4.x - /opt/alt/ruby24/bin/ruby
  • Ruby 2.5.x - /opt/alt/ruby25/bin/ruby
  • Ruby 2.6.x - /opt/alt/ruby26/bin/ruby
We currently run Litespeed Web Server which runs PHP as the user so files and folders should have the permissions of:

  • Folders: 755 (drwxr-xr-x)
  • Files: 644 (-rw-r--r--)

Even if the instructions for the software state to change the permissions of files or folders to 777 or 666 don't do it. It's a security risk and not needed in our environment.

If you accidently have changed the permissions on your account and your website no longer works please contact the support department to fix the permissions on your account.
Yes we support Ruby On Rails and you can install and utilize many different versions of Ruby and Rails utilising our "Create Ruby App" option.  You can find more information on how to create a Ruby Application at:  https://support.hawkhost.com/index.php?/Knowledgebase/Article/View/188/0/how-to-create-ruby-application

We fully support Zend Framework on all of our shared, cloud web hosting, semi-dedicated, and reseller hosting plans. While we do not have a system wide install available for use, all users are able to upload the framework themselves and run it from within their account. All of the required modules are loaded and Zend Optimizer is installed.

We recommend installing it through Softaculous which is available in your cPanel account. If you need assistance installing it please submit a ticket to our helpdesk.


Yes, Litespeed is capable of utilizing GZIP compression to help speed up your site.

Yes, Litespeed is fully compatible with Apache's mod_rewrite module.

We currently do not make use of PHP safe_mode.
You can change PHP configuration values by modifying your .htaccess file and using the php_flag command.

Here is an example turning on error_reporting:

# E_WARNING & ~E_NOTICE
php_flag error_reporting 2
Our servers by default do not enable any sort of server based caching of your Cascading Style Sheets (CSS).  The majority of browsers however do caching of css, images and java script files which is most likely what is happening if you believe the files are cached.  You can tell your browser to do a hard refresh and re-download everything by doing ctrl+f5 in the majority of browsers opposed to the normal f5 which is simply a normal refresh of the page.
The best way to find the PHP configuration information for the specific server you're on is to make a phpinfo file. Create a file called phpinfo.php with the following code:

<?php
phpinfo();
?>

Once you've created the file upload phpinfo.php to your public_html folder on your web space. Now visit this page in your browser by going to http://www.yourdomain.com/phpinfo.php (replacing yourdomain.com with your actual domain). This will give you our current PHP5 based configuration.

The PHP setting allow_url_include is disabled on all Hawk Host servers and for the protection of our users is a setting we do not allow to be overridden through our PHP selector's setting system. The allow_url_include directive is by default disabled in PHP and as of PHP 7.4 is deprecated and will produce an error when enabled.

The allow_url_include directive makes the functions include, include_once, require and require_once URL aware which has major security implications. When used it will execute anything remotely as PHP which means if you're including a remote website it could easily injection PHP code into your website. This capability also is frequently used in malicious files and exploits within software. Here are some examples of it being used and alternative methods so that you do not need this setting:

The developer needs to include additional PHP files within their index.php of the website uses:

<php include("http://mywebsite.com/includes/header.php"); ?>

This can alternatively be written as:

<php include("includes/header.php"); ?>

This is not only safe but quicker than remotely visiting your website for the header contents.

There may also be cases where it's being used to add external content from another website and may look like this:

<?php include("http://www.otherwebsite.com/scores.txt"); ?>

You could alternatively write this as:

<?php print file_get_contents("http://www.otherwebsite.com/scores.txt"); ?> ?>

Keep in mind however printing contents from a remote website can be dangerous for website visitors as it could contain malicious html/javascript code but this will not execute PHP code which makes it safer for your website.

If you have third party applications and developers still insisting it is necessary to turn allow_url_include on we recommend linking them to this article and many others on the internet which discuss how dangerous allow_url_include on is.

The expose_php setting reveals that PHP is installed on the server, which includes the PHP version within the HTTP header (e.g., X-Powered-By: PHP/7.3.13). The default PHP value is for this setting to be on and by default we use all reasonable PHP default settings for maximum compatibility. You can however set expose_php to off by doing the following:

  1. Login to your cPanel for your account.

  2. Use the top search to locate the "Select PHP Version" in your cPanel:

  3. Once on this page you'll select the "Options" menu button which will bring you to the majority of the PHP settings we allow you to override

  4. On the expose_php setting change it from being checked to unchecked and this will turn set expose_php to off
We support the ability to deploy Node.js Applications utilizing mod_passenger through our cPanel page using our "Setup Node.js App" page


On this page you will need to choose to create an application and on the create application page you'll be asked:

  • Node.js version
  • Application mode
  • Application root
  • Application URL
  • Application startup file



Once completed you'll have the ability to run "npm install" if you have a package.json file



You can see all your applications under the web application option. On this page you'll see various pieces of information about your application as well as the ability to stop, restart, edit and delete your applications

This article advises you on how to create a node.js application using a cron jobs and php. This is no longer necessary you can do it from our own interface and there exists a guide at https://support.hawkhost.com/index.php?/Knowledgebase/Article/View/197/0/how-to-create-a-nodejs-application . However for users using this method it remains accessible for their reference.

At Hawk Host it is possible to create persistent Node.JS applications utilizing several of our built in features.  We will walk you through how to create a node.js hello world but the same can be applied to applications such as Ghost

1) You'll need to create a nodejs folder within your accounts home directory which can be completed by FTP/SFTP or throuhg the cPanel file manager.  After this is created you will create an app.js file inside your nodejs folder with the following contents:

var http = require('http');

http.createServer(function (request, response) {
    response.writeHead(200, {'Content-Type': 'text/plain'});
    response.end('Hello World\n');
}).listen('12345');

console.log('Server started');


Replace 12345 with a randomly generated 5 digit number and record this as it'll be necessary later on.

2)  You now need to create a PHP file which will be used to manage your application.  Create a cron.php file with the following contents:

<?php

$host = '127.0.0.1';
$port = '12345';
$checkconn = @fsockopen($host, $port, $errno, $errstr, 5);
if(empty($checkconn)){
     exec('/usr/bin/node /home/'.get_current_user().'/nodejs/app.js > /dev/null 2>&1 &');
}


Change the 12345 to contain the port number you randomly generated previously.

3)  You will now need to login to cPanel and open the cron jobs option



You will need to create a cron job with the following settings:




The cronjob command is

/usr/local/bin/php /home/username/nodejs/cron.php > /dev/null 2>&1

Replace username with your accounts username.

4) The final step is to make it possible for the web server to connect to your Node.JS application.  Navigate to where you wish for your application to load from which in our case will be the public_html folder.  Create a .htaccess file with the following contents:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ http://127.0.0.1:12345/$1 [P,L]


Replace 12345 with your random port you generated and upon visiting the location your Node.JS application should now load.

We support the ability to deploy Python Applications utilizing mod_passenger through our cPanel page using our "Setup Python App" interface. You can find this interface by logging in to your accounts cPanel and use the search to look for "Python":



From the select Python interface in cPanel you have the ability to use any of the following Python versions:

  • Python 2.7
  • Python 3.3
  • Python 3.4
  • Python 3.5
  • Python 3.6
  • Python 3.7
  • Python 3.8

In addition to creating a new Python application our interface also allows you to:

  • Utilize Environment Variables. These can be added when deploying your app or they can be added later through the same interface.
  • The ability to start/stop/restart your app.
  • Configuration Files can be managed for existing application through a UI instead of relying on CLI.
  • Instead of managing modules individually, all required modules for an application can be installed by specifying the proper requirements files and triggering an installation action via the UI

To properly deploy your Python application you will need first need to select the "Create Application" button from the middle-right of the Python page:




  1. Start by choosing your desired Python version.

  2. You will then need to select an Application Root directory. The Application Root directory is preferably within your domains home directory and this is where you will upload your application files. For purposes of our example we'll use the directory /home/username/public_html/python for our Application Root

  3. Your Application URL should be the publicly accessible URL which corresponds to your Application Root from step 2.

  4. You can leave the Application Startup File and Application Entry Point fields empty unless you have reason to explicitly set them for your application. The Passenger Log File will be pointed at your home directory by default.

  5. Click "Create" once you have finished filling out the fields. Your application will be created:


Once the above steps have been completed you will see the application listed under the Web Applications table:

We support the ability to deploy Ruby Applications utilizing mod_passenger through our cPanel page using our "Setup Ruby App" page


On this page you have the option to select the following Ruby versions:

  • Ruby 1.8
  • Ruby 1.9
  • Ruby 2.0
  • Ruby 2.1
  • Ruby 2.2
  • Ruby 2.3
  • Ruby 2.4
  • Ruby 2.5
  • Ruby 2.6

To properly deploy your Ruby application you will need to select a directory for your application that is preferably within your home directory for example "ruby".  Then you also select the location of your application including Domain and URI.  Upon filling out these portions you will click the setup button.


Once completed your application will appear as an existing application



You can easily install additional Ruby modules including popular ones like Rails by utilizing the modules option:

Once added and saved your additional module will appear along with the version


Yarn is an alternative package manager for JavaScript which many prefer over npm. You can easily install it by logging into SSH on your account then running the following commands:

npm install yarn
echo "alias yarn='node_modules/yarn/bin/yarn'" >> .bashrc && . ~/.bashrc

After this you can use 'yarn' on your account

We do not recommend you run PHP without web server timeouts on web requests but instead if you need a long running PHP process you run it from a cron job or from SSH if it's a one time operation. There however may be cases such as Wordpress plugins where it must be ran by visiting a URI. You can disable web server PHP timeouts by doing the following:

To disable all timeouts you can add the following to your .htaccess file:

<IfModule Litespeed> 
SetEnv noabort 1
</IfModule>

If you wish to only have no timeouts for certain requests such as for example wp-cron, backupbuddy or importbuddy you could use the following:

RewriteEngine On
RewriteRule (wp-cron|backupbuddy|importbuddy)\.php - [E=noabort:1]

Keep in mind you may also need to modify the PHP max_execution time if your application does not modify this for you.


You can install PEAR packages by doing the following:

1) Locate the "PHP Pear Packages" option within cPanel

2) You'll be prompted with a screen to manage and manipulate your current PEAR extensions.

By default there is no console location defined for Node.js applications. You can define one by setting an environmental variable LSNODE_CONSOLE_LOG and the desired location of your log file. To set an environmental variable you navigate to your Node.js application list and click edit on the desired application. On this page there will be an option to define environment variables:

You will add the following:

Name: LSNODE_CONSOLE_LOG
Value: /home/username/pathtoapp/console.log

Adjust the value according to the desired location of your console.log. After you've set a value save your Node.js application and any further console activity will be written to the log file. You can test this by inserting the following code:

console.log('Testing logging');

For more advanced users you can also define the environment variable within the .htaccess file of the document root of your Node.js application. The format of that would be as follows:

<IfModule Litespeed>
SetEnv LSNODE_CONSOLE_LOG /home/username/nodeapp/console.log
</IfModule>


The PHP interpreter is commonly used in cron jobs to execute php code.

php /home/me/public_html/cron.php

for example will execute php under an account.

phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. phpMyAdmin supports a wide range of operations with MySQL. The most frequently used operations are supported by the user interface (managing databases, tables, fields, relations, indexes, users, permissions, etc), while you still have the ability to directly execute any SQL statement.

Note: You can access phpMyAdmin via cPanel
Note: Creation and management of users and databases is handled through cPanel
The PHP memory limit on any shared hosting plan is currently limited to 128MB.

You can access PHPMyAdmin by selecting the "phpmyadmin" option under the "Databases" option within cPanel.