1

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?

1 Answer 1

1

You shouldn't use root directive inside location blocks.

Try this:

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

With this configuration, URLs work like this:

http://example.com/develop/auth/image.png -> C:/webapps/develop/mil_catele_auth/public/image.png

If you use root instead of alias, you would get:

C:/webapps/develop/mil_catele_auth/public/develop/auth/image.png instead.

And then, for some non-existing file / directory:

http://example.com/develop/auth/not-existing -> C:/webapps/develop/mil_catele_auth/public/index.php would be run.

Hope this works the way you want it to work.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.