PowWeb Web Host Tips and Tricks

PowWeb Web Host Tips and Tricks

This post contains affiliate links to products which we hope are of value to you, and on which we receive a commission.

This post contains some tips for getting the most out of your PowWeb web host.

Running PHP Scripts as Scheduled Tasks (Cron Jobs) on PowWeb

Scheduled tasks can be set up through the Scheduled Jobs page. If you want to run a PHP script, there are two options.

  • URL to Access – this is for when the script you want to run is publicly accessible via a URL. You need to specify the path relative to your htdocs folder. For example, if in the file manager your file path is given as /htdocs/mysite/scripts/myscript.php you would enter the URL to Access as /mysite/scripts/myscript.php
  • Command to Run – this is when you have a command line script to run. To run a PHP script, you need to use a specific command line version of PHP located at /usr/local/bin/php5-cli. You also need to use the full path to your script (you can the full path to your document root on the server information page). The final command will look something like: /usr/local/bin/php5-cli /home/users/web/b1234/pow.yourusername/myscripts/command_line_script.php 

Using file_get_contents() on PowWeb

PowWeb restrict the use of file_get_contents() for security reasons. This means if you want to load the content of a URL, you need to use something other than file_get_contents(). Curl is perfect for this, and you can use the following function as a direct replacement for file_get_contents():

function curl_get_contents($url) {
  $curl = curl_init();
  curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER=>1, CURLOPT_URL=>$url));
  $result = curl_exec($curl);
  return $result;

Connecting to PowWeb via SFTP

The powweb control panel allows you to set up FTP access to your files, via the FTP settings page.

What it doesn’t make obvious is that you can use the same FTP account settings to access your files via the more secure SFTP (Secure-FTP) protocol. To do that, simply use your SFTP client to connect to powweb using the following settings:

  • host = ftp.powweb.com
  • port = 2222

Use the username / password that you set up on the FTP settings page.

Scheduling Command Line Jobs

The Scheduled Jobs page allows you to configure recurring tasks (aka cron jobs). The page offers two options – you can provide a URL to a script you want to run, or provide a command you want. I’ve successfully scheduled commands to run in the past, but today when I tried all I got was a “forbidden” error. I contacted support and this is what they said:

The ‘Command to Run’ option does not work in Scheduled Jobs. You need to set the ‘URL to Access’. This can be URL to a PHP or Perl script you have created that performs an action on your website.

So it looks like it’s URL only scheduled tasks for the time being. Functionally, this shouldn’t change things – just have perl or php execute the command you need to run. But from a security point of view, it’s worth noting that by default anyone will be able to access the URL and run your task at times other than those you schedule, so you may want to take measures to defend against that.

Accessing SQLite Databases

If you try to access an SQLite database via PHP’s PDO, you may get an error like:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [14] unable to open database file'

I did and found that I needed to supply the full path of the database file when opening the database file. That is, I had to change:

$db = new PDO('sqlite:filename.db');


$db = new PDO('sqlite:'.dirname(__FILE__).'/filename.db');

The other thing to make sure is that you have the correct permissions on both the file and the containing directory (i.e. that you have the ‘read’ permission set if you are reading from the database and the ‘write’ permission set if you are updating it.


Let's Discuss...

Add a Comment