This article provides essential information about running PHP scripts on A2 Hosting servers.
To avoid potential problems, you should set your PHP script file permissions to 755 (read, write, and execute permissions for the user, and read and execute permissions for the group and world).
No. You do not need to add a #!/usr/bin/php header (shebang) to your PHP script files.
Yes, we have installed support for short tags with PHP. This means that you can write:
<? echo "Hello world"; ?>
<?php echo "Hello world"; ?>
The absolute path to the PHP executable on A2 Hosting's servers is /usr/bin/php. The /usr/bin directory is in the default path, so generally you do not need to include the full path when you run PHP scripts from the command line. Just type the following command, replacing filename with the name of your script file:
However, if you want to run an alternate PHP version from the command line, you must specify the full path to the executable. To see the PHP versions that are available on your account, type the following command:
Each PHP version has its own directory in the /opt/php directory, and the PHP executable is located in the version's bin directory. For example, if you want to run a file named test.php from the command line using PHP version 5.5, type the following command:
Currently, you can use PHP version 5.6, 7.1-7.4, 8.0 or 8.1.
The default file extension for PHP script files is .php. However, you can define additional PHP script file extensions in an .htaccess file. For example, the following line demonstrates how to define the file extension .html for PHP script files:
AddHandler application/x-httpd-lsphp .html
For more information about how to use .htaccess files, please see this article.
No, we do not run PHP on our shared servers with safe_mode enabled, because it can cause issues for scripts. Additionally, safe mode is deprecated in PHP 5.3.0, and completely removed in PHP 5.4.0.
For more information about PHP, please visit http://www.php.net.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.