Jelastic PHP Developer’s Center

php_3.pngBeing truly multilingual, Jelastic Cloud can be leveraged by developers as a single platform for hosting all their applications, regardless of the programming language they were written in - Java, PHP, Ruby, Python, Node.js or .NET. Besides the support of the majority of popular engines, Jelastic ensures a very easy deployment workflow, as it doesn’t require any code changes and is optimised for automation. Moreover, due to the specifics of the implementation and virtualization technologies used, it offers numerous extra opportunities and configurations for your apps.

This guide will acquaint you with the distinctive features of PHP hosting and provide a general overview of PHP-related possibilities you receive while working with Jelastic. Use the index below to find the information you are interested in and jump to the corresponding section to get the details, including links to the related instructions and tutorials.

PHP Hosting Environment

In order to get started with hosting of your PHP application, you need to create an appropriate environment, which represents a collection of containers intended to work together for serving this app (or part of it). This can be done through the Environment Topology wizard within your Jelastic dashboard - just navigate to its PHP engine tab, pick the desired set of servers required for your app, and preconfigure them according to your needs.


All added servers represent fully isolated containers, located on different hosts for more availability, while isolation eliminates the risks of interfering with one another or by other users. You have an ability to attach the Public IP address to any of these servers for being accessed directly. Otherwise (i.e. if using default settings), the incoming requests sent to your application will be proxied by Shared Resolver.

To get additional information on setting up a suitable environment, see the Create Environment document. It provides details on what can be configured through the environment topology wizard and how it's done.

PHP Application Servers

Jelastic supports the following PHP application servers that are provided as dockerized templates:

Use the PHP App Server Configuration article to examine how these servers can be configured and find the list of editable config files for each of them.

Instructions on the main extra functionality and possibilities, available to be configured for the abovementioned nodes, are summarised below within this guide.

PHP Versions

There are four PHP versions available at Jelastic:
  • PHP 5.3
  • PHP 5.4
  • PHP 5.5
  • PHP 5.6
  • PHP 7.0
  • PHP 7.1

You can choose the preferred version while creating an environment, or change it later. These procedures are described in the PHP Versions document.

Application Deployment

Once the appropriate environment is created, you can deploy your application into it.

Jelastic provides multiple deployment methods, using:
  • .tar, .tar.gz, .zip and .bzip2  archives
    • downloaded from a remote URL (http://, https:// or ftp://), or
    • uploaded via the Jelastic dashboard
  • GIT/SVN remote repository

If you’d like to use the archive-based deployment, simply follow the instructions in the Upload and Deploy Your PHP Project article.

If you prefer deployment from GIT/SVN, then navigate to the document Deploy Your PHP Project via GIT/SVN. In addition, you can configure an automatic periodic re-deployment of your project from the repository, which is only performed if the repository contains new code changes.

There are also separate instructions for working with Bitbucket GIT repos and managing your PHP projects via Gitblit.

PHP Hosting Specifications

This section is devoted to the essential specifications of PHP application’s hosting at Jelastic Cloud.

  • Public IP: One of the most distinctive Jelastic features is an ability to attach the Public IP address to any instance in the environment. This increases stability of your production applications by eliminating a shared infrastructure component from your topology (the Shared Resolver) and routes all of the incoming traffic directly to your server instead. Addition of an external IP can also provide remote access to a specific environment node (e.g. a database server) that is not otherwise Internet-accessible, or allows the use of other ports and protocols, which are not supported by the Shared Resolver. For more information on the benefits the Public IP gives you, read the corresponding article in our documentation. As an alternative to Public IP, you can use Endpoints that allow to establish a direct connection to the corresponding node over either raw TCP or UDP protocol.

  • Automatic Vertical Scaling: Providing truly elastic hosting, Jelastic is equipped with one more innovative feature - automatic vertical scaling of your application. It is made possible by the platform's ability to change the amount of resources (RAM and CPU), provided to any container, on the fly by tracking the incoming load in real time. This feature guarantees you will never overpay for unused resources, and ensures very granular and fair pricing. See the full article - Automatic Vertical Scaling.

  • Multiple Middleware Stacks: Jelastic also allows you to change the number of any servers in your environment thanks to the multiple middleware stacks support. To ensure even more reliability and high-availability, all the newly added nodes are created on different hardware nodes. For additional information navigate to the Multi Nodes page.

  • Automatic Horizontal Scaling: The number of the application server nodes can also be scaled automatically by means of tunable triggers. The automatic addition/removal of app servers depends on the resource usage of your application. To find out how to implement this, get acquainted with the Automatic Horizontal Scaling document.

  • WebSockets: Using this technology can make your applications faster and more efficient due to establishing a continuous full duplex connection between client and server. Communication over this TCP-based protocol results in a rapid interaction and ensures streaming through proxies and firewalls, both upstream and downstream at once. Learn how to enable WebSockets support on Jelastic.

Extra Functionality

Jelastic offers significant flexibility and control of your application servers' configuration. This overview of PHP computing nodes’ configuration lists the available configuration files and provides the basic information for what you may configure, and where to do so. Also, there is a separate guide explaining how to set your custom environment variables for any desired server via SSH.

And some of the most important features and solutions, provided for PHP application’s hosting on Jelastic Cloud, are summarised below.

Domains Management


  • For production purposes, you can bind an external domain name to your application’s URL, i.e. use your own custom domains instead of the default environment domain name. This can be done in two ways: using either CNAME or A Record.
  • With the help of the swapping domains feature, you can upgrade and modify your application with zero downtime so your users won’t notice any interruption. Detailed instructions on this procedure are provided here.
  • Using multiple domains with a single environment increases its usability, efficiency and scalability, whilst simultaneously saving your costs by avoiding a need to set up  separate environments for different apps. See the Multiple Domains for PHP document in order to find out how this can be implemented within Jelastic PaaS.

Security


  • SSL / TLS (Secure Sockets Layer / Transport Layer Security) is the industry standard security technology for establishing an encrypted connection between a web server and a browser. This technology ensures that all data passed between them remains private and confidential, i.e. it can’t be intercepted by a third party.
  • You may also place an NGINX-balancer node in front of your application, with the appropriate security configurations set, to restrict application access by source IP address, or limit access by username/password through implementing the basic HTTP authentication. We provide examples of such settings in the Security of App with NGINX Balancer article.
  • Besides the common protection methods, security of your PHP application can be increased through customizing the main PHP configuration file, named php.ini. You can edit a number of default settings it contains or add your own in accordance to the needs of your application. In order to discover more details, navigate to the PHP.INI Security Settings document.
  • Also, additional security configuration guidance is available for particular app servers:

Clustering


  • Implementing the PHP sessions clustering solution for your application can highly increase its availability and failover capabilities by means of using the sticky sessions, run on several app server nodes. This mechanism in ensured by a Memcached node, that should be added to your environment and used as storage for the processed sessions’ backups. The corresponding configuration workflow can be found within the PHP Sessions Clustering tutorial.
  • Using multiple app server nodes brings one more benefit - Data Synchronization. Just scale out the server with your deployed application and get its exact copy with all the same configurations and files inside. Besides that, we have a separate instruction on configuring the continuous file synchronization between several app server nodes with the help of an external lsync tool - see the corresponding guidance here.

Job Scheduling


  • Jelastic provides the ability to run certain operations at a specified time with the help of job scheduling services, which can be integrated to any PHP application. Here are the instructions on how it can be done via Cron and Quartz.


Modules


  • While working with Jelastic PaaS, you receive an opportunity to extend the functionality of your environment through setting different PHP extensions at the appropriate application servers. You can either select one of the supported by default extensions and activate it, or upload your own custom one - both these operations are described in the PHP Modules instruction.
  • As a separate kind of PHP extension, PHP accelerators can be determined. They are used for enlarging your app’s efficiency through caching the already compiled parts of PHP code, which can be quickly executed upon a user’s request. The way this mechanism works and the required steps for its enabling are provided within the PHP Accelerators guide.
  • Both of the available PHP app servers also include a particular set of the in-built modules. For the Apache node, this list can be enlarged by means of adding your custom module according to this workflow.
  • In addition, there are a few separate tutorials on configuring the following supported modules:

Useful Tools


  • With Jelastic, you are able to have multiple web-sites with different virtual host names running on the same IP address within the same server. For more information read the Name-Based Virtual Host in Apache article.
  • Putting Apache in front of Tomcat is widely used for improving the high-load environments’ performance. Beside this, Apache as Frontend brings some additional functionality, e.g. high availability through performing the load balancing among multiple Tomcat servers, fast processing and delivering of static content, additional security and extra functions via Apache modules and so on.
  • Caching in NGINX is the process of storing the oftenly requested data in front of web servers, aimed for reducing time and traffic consumption. This is achieved through copying the files closer to a user and accelerating resources’ building by decreasing the number of users accessing them.
  • Sending emails via the SMTP protocol is a widely spread mechanism for performing mailings through the IP networks. Our documentation provides two ways of such a solution’s integration into your PHP application: through using the external PHPMailer class and through implementing the custom sending form at the desired app page.
  • Managing all the required libraries and packages of your application by means of PHP Composer. Running on a per-project basis, Composer determines which versions of which packages your project depends on and installs them in a working directory.

PHP Tutorials

Jelastic Devs Center also contains numerous tutorials on different PHP applications’ deployment. The full list of instructions is available at the PHP Tutorials page.

In addition, you can gain the extra availability, redundancy and scalability strengths for your application by means of configuring a clustering solution. A cluster ensures that no server is a single point of failure for an application, and Jelastic's unique Cloud infrastructure ensures that one server’s failure won’t overload the rest of them in the cluster.

Here are a few examples of clustering solutions configuration steps for some popular PHP apps: