Categories
cPanel PHP Scripts SSH Web-Hosting

Execute PHP script from cron or command-line

Execute PHP script from cron or command-line

One of the method for running PHP scripts from a cron job is run the script using php from the crontab. You will need to call the php script from your crontab as given below.
To execute somescript.php every 1 hour you will need to edit and add below given line in your crontab file:
00 * * * * /usr/local/bin/php /home/someuser/somescript.php

If you are looking for command-line interpreter, then it can be done with the following command. It shows how to run a script using the PHP command-line interpreter:

/usr/local/bin/php -q /home/someuser/public_html/somescript.php
The -q option is for quiet mode, to prevent headers being displayed.

Make a note of code in your PHP script, it may only run correctly if called from a mentioned path. For example, if the script uses relative paths to include files, it will only run if it is called from the specified directory. The following command shows how to run a PHP script from a specific path:

cd /home/username/public_html/; /usr/local/bin/php -q script.php

Related: Dedicated Server, Virtual Server, Web Server Hosting

Categories
Dedicated Server PHP Scripts Security Virtual Private Server Web-Hosting www

Captcha image is not working – Fatal error?

Captcha image is not working – Fatal error?

You have the GD image library installed and otherwise working.
Still unable to get captcha with the captcha plugin.

You are not sure what’s the problem as it works on one of your other sites.  When you try to include the captcha on your website or contact form it generates an error message like…
Call to undefined function imagettftext() OR
Fatal error: Call to undefined function imagettftext() in /home/user/public_html/appfolder/plugins/captcha/captcha.php on line 99  OR
Fatal error: Call to undefined function imagefttext() in /home/user/public_html/lib/captcha/captcha.php on line 329 OR
‘–enable-gd-native-ttf’

Problem could be, because the standard PHP “imagefttext()” function does not work on your server.
It can caused by the fact that there is no –enable-gd-native-ttf key installed on your server as the Cart uses GD Library for displaying the verification image.

Please note that PHP must be configured with the following keys:
–with-gd –enable-gd-native-ttf  Contact your host to make the change!

Any idea why or how it can be fixed?

imagettftext() is part of the GD image functions library, which is not always part of PHP (the code CMS/Cart runs on).
You need to contact your host and ask them to install the PHP GD library. It’s really simple for them to do and is fairly common, so if they give you a hard time about it, I would seriously consider switching to better and friendly host – UnicHost :).

Related: Web Server, PHP Hosting, LAMP Server, cPanel Hosting

Categories
Dedicated Server PHP Scripts Setup www

phpinfo.php file on server

How to check php settings by using phpinfo on server?

Each server is setup differently whether it is a dedicated server or a virtual server, phpinfo() is commonly used to check configuration settings and for available predefined variables on a given web server.

phpinfo() is a valuable debugging tool as it contains all the data, information related to environment, GET, POST, Cookie, Server etc.

To create the file simply add the following lines of code to a blank document.
<?php
phpinfo();
?>

Save the file as phpinfo.php and place it in the desired directory. Lastly, call the script from a browser.

http://www.your-own-website-example.com/folder/phpinfo.php

This php file will output detail information about the current state of PHP: PHP compilation options and extensions, the PHP version, server information and environment, the PHP environment, OS version information, paths, master and local values of configuration options, HTTP headers, and the PHP License as well.

Related: PHP Hosting, LAMP Server, cPanel Hosting