Deploying Code with Zend Server

This procedure describes how to manually deploy your PHP code to run with Zend Server.

Note:

Zend Server Deployment feature is the easiest and most powerful method of using Continuous Integration and package deployment on Zend Server (standalone or cluster of servers). For information on deploying applications with Zend Server, see Working with Applications.

Zend Server provides all the components for creating an environment suitable for developing and deploying PHP applications.To run a PHP Application you need a Web server. Apache is bundled by default with Zend Server and is used to run your PHP code. This option may vary depending on your operating system. For instance, for Linux, Zend Server uses the distribution's Apache and for Windows and MAC OS X, Apache Web server is bundled with the Zend Server installation.

Note:

If you are using Windows OS, please note that the Zend Server Deployment feature is not available for IIS.

The process of writing PHP applications is separated into two distinct sections: Development and Production.

  • Development includes developing and debugging your code. In most cases, this is done on a developer's machine or on a remote server with limited or password-protected access.
  • Production is when the Web application has reached a level of maturity that allows it to be exposed to its target audience. The only tasks that should be done are debugging (remote) and uploading changes. It is against best practices to make changes to code running on a Production server and the preferred method is to use FTP/SFTP to upload changes.

Development

Where to Put the Code?

In order to run a PHP application, your PHP files must be placed in a specific location that indicates to the Web server what files to service.

When you are ready to run your PHP code on a Web server, place the files under the following directory according to your operating system and preferences:

Windows:   

  • <install_dir>\Apache2\htdocs

  • With IIS: C:\inetpub\wwwroot\

Mac :

  • <install_path>/apache2/htdocs

DEB:

  • The distribution's default location is: /var/www/html

RPM:

  • The distribution's default location is: /var/www/html

IBM i:

  • /www/zendphp7/htdocs

Running the Code/Application

Open a browser and enter the URL (HTTP) in this format:

http://<HOSTNAME>:<PORT>/<PHPfile>.php


<HOSTNAME>: Replace with localhost/127.0.0.1 is the server is installed on your current system. If you are using a virtual host, use the host name of the virtual host to make HTTP requests aware of the host and retain domain related functionality (if your code is domain aware). If you are calling your PHP script from another machine, use the correct Host Name / IP.

<PORT>: Replace with the correct TCP port for your OS:

Windows / Linux / Others when set: 80

Mac OS X: 10088 (you can change this to 80 in the Apache config Listen directive, it is set different by default to allow the default Mac Apache to run on port 80 without conflicting Zend Server).

IBM i: 10090

<PHPfile>.php: Replace with your own path/file holding the application index / main file.

 

To run HTTPS instead of HTTP requests, you need to make you SSL module is enabled with correct certificate and port 443 is assigned to your SSL vhost.

Note:

To find out how to locally debug your code once it's deployed in a Web server, see Working with Local Debugging.

Production

Deploying code to production is different than running your application in a controlled environment (such as a local server). Production means publishing your application to the internet.

 

So where do you publish your application?

Depending on the resources available to you, you either have a different server that is dedicated to servicing the web or a cluster of servers that are managed with a load balancer. In both cases, a firewall or some other protection is necessary.

An additional option is to have your application run from a Web Hosting company.

 

Once your code is in its dedicated location, you will have to support the code so you will need to establish a way to upload files for purposes of issuing updates and fixing bugs or security threats. At this point if you have been locally debugging your code with Zend Studio you can now change your settings to remote debugging, if there is a firewall between you and your application's files you will need to use tunneling in order to debug through a firewall. Zend Studio users can also benefit from Remote Server support for uploading and synchronize your code.