Moving Zend Framework 2 from apache to nginx

Posted by Aleksander on Server Fault See other posts from Server Fault or by Aleksander
Published on 2014-08-20T08:03:23Z Indexed on 2014/08/20 10:23 UTC
Read the original article Hit count: 344

I would like to move site that uses Zend Framework 2 from Apache to Nginx. The problem is that site have 6 modules, and apache handles it by aliases defined in httpd-vhosts.conf,

#httpd-vhosts.conf
<VirtualHost _default_:443>
ServerName localhost:443

Alias /develop/cpanel "C:/webapps/develop/mil_catele_cp/public"
Alias /develop/docs/tech "C:/webapps/develop/mil_catele_tech_docs/public"
Alias /develop/docs "C:/webapps/develop/mil_catele_docs/public"
Alias /develop/auth "C:/webapps/develop/mil_catele_auth/public"
Alias /develop "C:/webapps/develop/mil_web_dicom_viewer/public" 

DocumentRoot "C:/webapps/mil_catele_homepage"
</VirtualHost>

in httpd.conf DocumentRoot is set to C:/webapps. Sites are avialeble at for example localhost/develop/cpanel. Framework handles further routing.

In Nginx I was able to make only one site available by specifing root C:/webapps/develop/mil_catele_tech_docs/public; in server block. It works only because docs module don't depend on auth like others, and site was at localhost/.

In next attempt:

root   C:/webapps;
location  /develop/auth {
    root   C:/webapps/develop/mil_catele_auth/public;
    try_files $uri $uri/ /develop/mil_catele_auth/public/index.php$is_args$args;
}

Now as I enter localhost/develop/cpanel it gets to correct index.php but can't find any resources (css,js files). I have no Idea why reference paths in browswer's GET requsts changed to https://localhost/css/bootstrap.css form https://localhost/develop/auth/css/bootstrap.css as it was on apache. This root directive seems not working.

Nginx handles php by using fastCGI

location ~ \.(php|phtml)?$ {        
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param   APPLICATION_ENV  production;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

I googled whole day, and found nothing usefull. Can someone help me make this configuration work like on Apache?

© Server Fault or respective owner

Related posts about apache-2.2

Related posts about nginx