How to run a zend-expressive project on my production server?


I try for a few days now to run a project zend-expressive on my production server but I can not.
The production server has the following configuration:

CentOS Linux release 7.2.1511 (Core)

PHP 5.6.20 (cli) (built: Apr 2 2016 07:51:15)
Copyright © 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright © 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright © 1999-2016, by Zend Technologies

Server version: Apache / 2.4.6

Loaded Modules:
core_module (static), so_module (static), http_module (static), access_compat_module (shared), shares_module (shared), shared_module (shared), allowmethods_module (shared), auth_basic_module (shared), auth_digest_module (shared), authn_anon_module (shared), authn_core_module (shared), authn_dbd_module (shared), authn_dbm_module (shared), authn_file_module (shared), authn_socache_module (shared), authz_core_module (shared), authz_dbd_module (shared), authz_dbm_module (shared), authz_groupfile_module (shared), authz_host_module (shared), authz_owner_module (shared), authz_user_module (shared), autoindex_module (shared), cache_module (shared), cache_disk_module (shared), data_module (shared), dbd_module (shared), deflate_module (shared), dir_module (shared), dumpio_module (shared), echo_module (shared), env_module (shared), expires_module (shared), ext_filter_module (shared), filter_module (shared), headers_module (shared), include_module (shared), info_module (shared), log_config_module (shared), shared (shared), mime_magic_module (shared), mime_module (shared), shared_module (shared), remote_module (shared), shared (shared), rewtime_module (shared), setenvif_module (shared), slotmem_plain_module (shared), slotmem_shm_module (shared), socache_dbm_module (shared), socache_memcache_module (shared), shared_share (shared) shared, dav_module (shared), dav_module_module (shared), dav_module_module (shared), dav_module_module (shared), shared_module (shared), shared_module (shared), shared_module (shared), shared_module (shared), sharedmodule (shared), lbmethod_heartbeat_module (shared), proxy_ajp_module (shared), proxy_balancer_module (shared), proxy_connect_module (shared), proxy_express_module (shared), proxy_fcgi_m shared, proxy_fdpass_module (shared), proxy_ftp_module (shared), proxy_http_module (shared), proxy_scgi_module (shared), proxy_wstunnel_module (shared), ssl_module (shared), systemd_module (shared), cgi_module (shared), ldap_module (shared), authnz_ldap_module (shared), php5_module (shared)

the z_default.conf file:

NameVirtualHost *: 80
<VirtualHost *: 80>
        ServerAdmin webmaster @ localhost
ServerName prod.service
        DocumentRoot /var/www/

ErrorLog /etc/httpd/logs/error_log
        # Possible values ​​include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
CustomLog /etc/httpd/logs/access_log combined
ServerSignature On

        <Directory />
                FollowSymLinks options
                AllowOverride None

Include /etc/httpd/conf.d/applications/*.conf
</ VirtualHost>

In the file /etc/httpd/conf.d/applications/expressive.conf:

Alias ​​/expressive "/data/expressive"
<Directory "/data/expressive">
Options Indexes MultiViews FollowSymlinks
AllowOverride None
Require all granted

I think I have everything for the configuration.

To create my project I use the following command in the directory /data/:

composer create-project zendframework/zend-expressive-expressive skeleton

I select modular, zend-servicemanager, fast router and flat template and whoops

I am giving a 404 error when I want to display the homepage in my browser.

I followed the following instructions:

I used los/basepath

and I still get a 404 error, I had to add this line to the /config/pipeline.php file just before routing:

$ App-> pipe (LosMiddleware\BasePath\BasePath::class);

Finally the home page is displayed but the problem is that when I click on the link “ping test” I get an error “/api/ping not found”.

Would you have a solution to this problem?
thanks in advance


You might want to start with PHP 7.1. All recently released expressive packages and new features require 7.1.

It’s been a while since I’ve written a apache config but it sounds like an issue with the RewriteRule in .htaccess. I think it should be something like:

RewriteEngine On
RewriteRule (.*) ./public/$1


In addition to the php version issue, at a glance it appears that you have an Apache documentroot issue as well. The vhost has DocumentRoot /var/www/. What’s in that dir? I see you’re also using an alias for “/expressive” and setting Options, etc for that dir. I believe you have a disconnect between your documentroot setting and the true location of what you need it to be.


First of all thank you for your answers, more I want to clarify that I am not the administrator of the server so I can only propose configuration changes, after he accepts or not.

An update of the PHP version of our production server was made during the release of version 7, but we did not dare to go directly. In addition, a big mapping and map provider application running on this server and moving to version 7.1 would involve more work for the developers of these applications. I’ll talk to our server administrator and maybe suggest to run 2 different versions of PHP.

yes I have that in my .htaccess file, as it is written in the documentation

There is no file.

Could you expand please? I try to configure the documentroot vhost like this:

DocumentRoot /data/

Since the vhost of my application is a subdirectory of “/data/”, but nothing changes, I still have the same problem.


The DocumentRoot for the Apache VirtualHost should be the location of your Expressive install. Specifically, the public directory. The .htaccess file that comes with the skeleton install is sufficient.

The documentation you referenced previously is for Expressive v2. Since you’re running PHP 5.6 on your server, this might be a requirement for you. Expressive v3 requires PHP 7.1 or later. I’d be remiss if I didn’t recommend upgrading to at least PHP 7.1 for many reasons but also to enable you to use Expressive v3.

If you really want to use v2, you’ll need to specify that when installing the skeleton. I think you can do that with something like this:

composer create-project zendframework/zend-expressive-skeleton <project-path> 2.2.*

That (as of today) will install the skeleton version 2.2.0 which has a dependency of Expressive ^2.2 which has support for PHP 5.6.