There was a problem loading the comments.

Using PHP 5

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Applicable Plans - All Cloud Hosting Plans

Using PHP 5

Overview

Note This User Guide is designed to help you install PHP 5 on your Virtual Server, and to do some minor configuration. This User Guide is not intended to be a tutorial on how to use PHP. You will need to consult the official PHP documentation or any of the 100+ available books about PHP if you need to come up to speed on how to actually use the language.

Installing PHP
    Installing PHP using the Control Panel
    Installing PHP using the command line

Installing PHP Extensions
    Viewing installed PHP extensions
    Installing additional PHP Extensions

PHP Configuration
    Common PHP configuration changes
    Changing PHP configuration using the Control Panel
    Changing PHP configuration using the command line

How to choose a different PHP version (Alternate PHP Versions - ISPmanager 5.3.1 and above)

PHP Accelerators, Loaders, and Frameworks


Installing PHP

PHP can be installed from the Control Panel and also from the command line of the Virtual Server.

Installing PHP using the Control Panel

Installing PHP using the ISPmanager Control Panel

If you are using the ISPmanager Control Panel, you can install PHP from that Control Panel.

  • For ISPmanager 4, go to Server Settings > Applications. In ISPmanager 4, PHP is called the PHP Scripting Language. More information on installing applications can be found here - Installing Server Applications.

  • For ISPmanager 5, go to Settings > Features. In ISPmanager 5, PHP is installed by clicking on Web-server (WWW) and then clicking on Edit in the upper left corner. Click on PHP and then on Apply Changes. More information on installing applications can be found here - Installing Features (Server Applications).

    NOTE - ISPmanager 5.31 and above have the option to install alternate versions of PHP. See the How to choose a different PHP version section of this user guide for more information. This is availble for both CentOS 6 and CentOS 7 OS Templates, with ISPmanager 5.31 and above only. This feature will enable you to deploy websites and web applications that require a different version of PHP than the one installed natively by ISPmanager in the Web-server (WWW) configuration.

Information on how to tell which version of ISPmanager you are using can be found here - ISPmanager versions

Installing PHP using the command line

PHP can be installed from the command line of the Virtual Server. You will need to log in to the Virtual Server using SSH and work as the root user. Install PHP with the yum install -y php command.

[root@eapps-example ~]# yum install -y php


Installing PHP Extensions

One of the strengths of PHP is the number of different extensions or modules available that can increase and expand its functionality. The PHP 5 application supplied by eApps comes with a large number of extensions pre-installed, and you are also able to install additional extensions using the Control Panel or the command line using PEAR and PECL.

Viewing installed PHP extensions

By default there are several PHP extensions installed. You can view the currently installed PHP extensions from the Control Panel or from the command line.

Viewing the installed PHP extensions using the ISPmanager Control Panel

  • For ISPmanager 4, go to Server Settings > PHP extensions. This lists all the available PHP extensions, and shows which ones are installed. Look under Status - a yellow light bulb means the extension is Enabled. A blue light bulb means the extension is Disabled, and a padlock means that extension cannot be disabled from ISPmanager because the extension is built-in to the version of PHP that is installed.

  • For ISPmanager 5, go to Settings > PHP extensions. This lists all the available PHP extensions, and shows which ones are installed. Look under Status - a yellow light bulb means the extension is Enabled. A blue light bulb means the extension is Disabled, and a padlock means that extension cannot be disabled from ISPmanager because the extension is built-in to the version of PHP that is installed.

Viewing the installed PHP extensions using the command line

You can also view the installed PHP extensions from the command line of the VS, with the php -m command.

[root@eapps-example ~]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
ereg
exif
fileinfo
filter
ftp
gettext
gmp
hash
iconv
libxml
openssl
pcntl
pcre
Phar
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
tokenizer
xml
zip
zlib

[Zend Modules]

[root@example ~]#

Installing additional PHP Extensions

If you need a PHP extension that is not currently installed, you can install it yourself. This can be done from either the Control Panel or the command line.

Installing PHP extensions from the ISPmanager Control Panel

  • For ISPmanager 4, go to Server Settings > PHP extensions. Click on Install in the upper right. This opens the Add PHP extension dialog. Click on the drop down arrow and select the extension you want to install from the list. The listing is in alphabetical order, but the extensions with names starting with uppercase letters are first, and then the extensions with names starting with lowercase letters are next. Once you have made your selection, click Ok.

  • For ISPmanager 5, go to Settings > PHP extensions. All the PHP extensions that are available to be installed from ISPmanager are listed here. The PHP extensions that are available to be installed have a blue light bulb in the Properties list. Click on the extension you want to install to highlight it, and then click Install in the upper left.

Installing from the command line

You can install PHP extensions from the command line using either pear or pecl.

Your Virtual Server has both pear and pecl installed, which means that you can install any modules from the http://php.net site.

To get the correct name for a Pear module, go the Pear packages page, and then click on the module itself. Then, click on the Download tab. The Easy Install section will have the correct command to install the module.

To get the correct name for a PECL module, go to the PECL packages page, click on the module name, and then look for the version you wish to install.

To install a pear or pecl module, use one of the following commands:

[root@eapps-example ~]# pear install module_name

[root@eapps-example ~]# pecl install module_name

Once the module is installed, it will need to be loaded into PHP so that it is available for use. To load the module into PHP, you will need to create a file in the /etc/php.d directory called module_name.ini that will contain the line:

extension=module_name.so

Do not use extension version numbers, just use the extension name.

Use one file for each extension. Also, some modules have their own list of variables, and those should be in the extension file, not in php.ini. Read the documentation for each module to see if you need to configure any variables for your modules.

After adding the extension files to the php.d directory, you will need to restart the Apache web server so that the extensions will be loaded into PHP.

  • For CentOS 6, use the service httpd restart command:

    [root@eapps-example ~]# service httpd restart

  • For CentOS 7, use the systemctl restart httpd command:

    [root@eapps-example ~]# systemctl restart httpd


PHP Configuration

For the majority of users, PHP as installed should require no additional configuration. However, there are some common PHP configuration changes that are made for application requirements or performance. These changes can be made from the Control Panel or the command line.

Common PHP configuration changes

Note Some PHP configuration changes can affect the security of your Virtual Server. Before making any changes to the default PHP configuration, make sure you understand any potential security risks. Also be aware that changing PHP settings may cause your application to no longer function and may cause issues with your Virtual Server. Make sure you understand the possible impact of any changes you make to the default PHP configuration.
  • Executing time - this is the maximum amount of time that PHP will wait for a script to finish. If the script does not finish is this time, PHP will kill the script.

  • Memory limit - this is the maximum amount of memory (RAM) that will be allocated to a script. If the script uses more than this amount of memory, it will be killed.

  • Request maximum size - this is the memory limit for a POST request

  • File minimum size - this is the maximum size of a file that a script can request. This is the parameter that controls the size of a file that applications like phpMyAdmin or phpPgAdmin can upload.

  • register_globals - unless you know exactly what register_globals does, and understand the security risks involves with turning it on, please leave it off.

  • display_errors - this will display any errors from the script to the browser. This is useful for debugging applications, but is a security risk if left on for production applications.

  • log_errors - this logs all PHP script errors to the error_log for the web site.

  • E-mail - if e-mails are sent from a PHP script, this is the address the e-mails are from. This must be an actual e-mail address on the Virtual Server, because the SMTP server will authenticate using that e-mail address. If this e-mail address is not valid, then any type of PHP mail script will fail.

Changing PHP configuration using the Control Panel

Changing PHP configuration using the ISPmanager Control Panel

From ISPmanager, you can make changes to certain PHP settings. What you are doing in editing the /etc/php.ini file, which controls all the PHP options.

  • For ISPmanager 4, go to Server Settings > PHP configuration. This will open the Edit PHP configuration dialog box. This shows the current PHP configuration defaults, and also the values you can change from ISPmanager 4. More information about PHP configuration in ISPmanager 4 can be found here - PHP configuration

  • For ISPmanager 5, go to Settings > PHP settings. This shows the full list of PHP configuration settings available. To see the list of the most commonly changed settings, click on Basic in the upper left. Otherwise, click on the Variable name you want to change, and then click on Edit in the upper left. More information about PHP configuration in ISPmanager 5 can be found here - PHP settings.

Changing PHP configuration using the command line

You can also make configuration changes to PHP by editing the /etc/php.ini file directly, which is the file being edited by the Control Panel. The same options are available. Make sure that after you make any changes to the php.ini file to restart the Apache web server.


How to choose a different PHP Version - Alternate PHP Versions (ISPmanager 5.31 and above only)

If you are using the ISPmanager Control Panel version 5.31.1 or above, you have the ability to install and use alternate versions of PHP on a per web-domain basis. This is available for both CentOS 6 and CentOS 7 OS Templates. This feature will enable you to deploy websites and web applications that require a different version of PHP than the one installed natively by ISPmanager in the Web-server (WWW) configuration.

To tell what version of ISPmanager you are on, log in as the root user, and then scroll all the way to the bottom of the left navigation pane. At the very bottom, you should see ISPmanager Lite 5.31.1 (or greater). If you do not see that version of ISPmanager 5, or you are on ISPmanager 4 and want to upgrade to ISPmanager 5, please contact eApps Support.

NOTE - the alternate PHP versions can only be run as CGI or FastCGI. Make sure your website or web application is configured correctly.

Installing the Alternate PHP Versions

To install the alternate PHP versions, go to Settings > Features, click on Alternate PHP versions, and then click on Install. This will show a dialog box with the versions of PHP to be installed, which you will need to confirm. This takes you back to the main Features screen. Wait about 5 minutes, and then click on Features again to see the status. Once the installation is complete, you will see a list of the available versions.

Click on Alternate PHP versions, and then click on Edit. This will allow you to select or deselect which versions you wish to use. Note that all are selected by default.

Using the Alternate PHP Versions

In order to use the alternate PHP versions, the user will need to have PHP as Apache module, PHP as CGI, and PHP as FastCGI (Apache) selected in Accounts > Users > {select the user} > Edit. Look for the Access section, and make sure those three items are checked. Then click Ok.

The alternate PHP version can be selected by either the root user, or by the actual website user.

  • For the root user: go to Domains > WWW-domains, and select the domain to change. Click on Edit, and under Aditional features set the PHP mode to be either CGI or FastCGI (Apache). This will open a PHP version menu item below where you can select your version of PHP. Once you have made your selection, click Ok.

  • For the user: go to WWW > WWW-domains, and select the domain to change. Click on Edit, and under Aditional features set the PHP mode to be either CGI or FastCGI (Apache). This will open a PHP version menu item below where you can select your version of PHP. Once you have made your selection, click Ok.

Once you have clicked Ok, the website or web application will now be able to use the alternate version of PHP.


PHP Accelerators, Loaders, and Frameworks

There are several applications that will allow you improve the speed of your PHP code, allow you to run PHP code that is encoded by ionCube, and allow you to take advantage of the Zend framework.

You can install ionCube Loader, and Zend Guard Loader These applications are installed from your Control Panel.

Installing using ISPmanager

  • For ISPmanager 4, go to Server Settings > Applications. Click on the application to install and then click on Install in the upper right. More information on installing applications in ISPmanager 4 can be found here - Installing Applications.

  • For ISPmanager 5, go to Settings > Features. Click on the application to install and then click on Install in the upper left. More information on installing applications in ISPmanager 5 can be found here - Installing Applications.

In order to have ionCube Loader and Zend Guard Loader installed together, they have to be installed in this order in the /etc/php.d directory:

ioncube-loader.ini
zend-guard-loader.ini 

By default, they will install in this exact order, unless you change the names of the configuration files in the /etc/php.d directory.

ionCube Loader

The ionCube Loader application allows you to execute ionCube encoded files. ionCube develops software products for PHP, including an encoder that protects and encrypts software written in PHP.

This is not the ionCube PHP Encoder. That product is only available from ionCube and requires a paid license.

Zend Guard Loader

Zend Guard Loader is required to run Zend Guard encoded PHP scripts. This is usually the case when you have purchased a commercial application that is written in PHP and encoded with Zend Guard.

Note Zend Optimizer is not compatible with PHP 5.3. If you are upgrading from PHP 5.2 with Zend Optimizer, you will need to upgrade PHP to the new version, and then install the Zend Guard Loader application from ISPmanager. Zend Guard Loader will replace Zend Optimizer. If you do not install Zend Guard Loader, your Zend Optimizer specific code will not work.


Share via
Did you find this article useful?  

Related Articles


On-Premise Help Desk Software by SupportPal

Categories

© Cloudscale365