This article provides instructions on how to implement the Zend framework 2 onto a shared hosting environment. Please note that this guide does not teach you about the Zend Framework 2 itself.
Starting with Zend Framework 2, you may now install using the PHP management tool Composer. This guide uses Composer to install version 2.5.
Please note that it's only possible to use composer if you're sites are on VPS or Dedicated server. This is due to the amount of resources it requires. If your sites are on a Shared server, you must install directly from the source files.
Step 1 — create a new user
View the Creating a user with Shell access article for details on how to create a new username. This allows you to log into your server to run commands later.
For security reasons, it is best to create a new user account to host the domain. Avoid hosting multiple domains on the same user account at all costs! If a hack compromises your account, all the domains running under that specific username can and will be affected.
Step 2 — create a fully hosted domain/subdomain
View the following article which walks you through how to add a fully hosted domain to your panel:
Make sure to assign the newly created Shell user to the domain when adding it.
Also make sure the domain is running on PHP 7.3 or above.
Step 3 — create a phprc file
View the following articles for instructions on how to create a phprc file.
If the file already exists, view the following articles for instructions on how to update it:
memory_limit = 300M
Raising the memory limit is for the installation process, otherwise it could possibly run out of memory and fail.
Step 4 — change the default PHP CLI your shell uses
If you wish to have your commands default to a specific version of PHP, view the following article:
Just make sure your shell PHP version defaults to the same version you're running the site under in your panel:
Step 5 — download Zend Framework 2.5
- Log into your server via SSH.
- Navigate into your website's directory. Make sure to change username to your Shell user.
[server]$ cd /home/username/example.com
- Close the repository.
[server]$ git clone git://github.com/zendframework/ZendSkeletonApplication.git
- Change directory.
[server]$ cd ZendSkeletonApplication
- The following folders and files have been created in this new directory
- Locally install Composer into this directory.
- Run the following to install ZendFramework 2:
[server]$ php composer.phar self-update [server]$ php composer.phar install
- This creates a new /vendor directory
- Change your site's web directory to /example.com/ZendSkeletonApplication/public/.
- Visit your site and you'll see ZendFramework 2 is running.