A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearZend Framework on nginx - page 1
User InfoPosts
Zend Framework on nginx#1
The Zend Framework based site I have been working on is now being migrated to its production server. This server turns out to be nginx (surprise!). Naturally the site does not work correctly as it was developed on Apache and relies on an htaccess file.

My question is... anyone have any experience with this? Any ideas on how to translate what the htaccess file does to an nginx.conf file? I'm researching this but am hoping someone already has experience with this. Thanks!

EDIT: This is the current htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

posted date: 2008-12-17 18:31:00


Re: Zend Framework on nginx#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-17 18:31:01


Re: Zend Framework on nginx#3
I don't know of any automatic/systematic way to convert the htaccess-file, you'll probably have to do it manually. The Nginx wiki is the best resource for nginx documentation.Edit:I'm running Zend Framework on Nginx myself now and the config looks like this:server { listen 80; server_name servername.com; root /var/www/zendapp/public; location / { index index.php; } # Deny access to sensitive files. location ~ (\.inc\.php|\.tpl|\.sql|\.tpl\.php|\.db)$ { deny all; } location ~ \.htaccess { deny all; } # Rewrite rule adapted from zendapp/public/.htaccess if (!-e $request_filename) { rewrite ^.*$ /index.php last; } # PHP scripts will be forwarded to fastcgi processess. # Remember that the `fastcgi_pass` directive must specify the same # port on which `spawn-fcgi` runs. location ~ \.php$ { include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } location = /50x.html { root /var/www/default; }}As you can see, the rewrite rule itself is very simple.

posted date: 2008-12-17 18:37:00


Re: Zend Framework on nginx#4
What do you have in your .htaccess?

posted date: 2008-12-17 18:51:00


Re: Zend Framework on nginx#5
I know it's a pretty old thread but it might help some people anyway.Basically it redirects any 404 error to index.php, but if the file exists (type file) it will set the right root.I did it from the top of my head. It might not be working right away, and you have to put the right path and fastcgi config. I also put everything back to index.php as it should work like that with Zend_Frameworkerror_page 404 = /index.php;location / { if (-f $request_filename) { root /var/www; }}location ~ \.php$ { fastcgi_pass unix:/tmp/php.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/index.php; include /etc/nginx/fastcgi_params;}

posted date: 2009-01-20 01:38:00


Re: Zend Framework on nginx#6
Thx stunti. That is helpful.

posted date: 2009-01-20 21:29:00


Re: Zend Framework on nginx#7
Actually i run a nginx with a drupal site that work like zend framework: one index.php as bootstrapthis is the rule (not tested on zend framework, just on drupal, but should be similar)location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?q=$1 last; break; } }error_page 404 /index.php;

posted date: 2009-03-22 16:35:00


Re: Zend Framework on nginx#8
If you use a subdirectory for your project like http://some.url/myproject/controller/, then you also need to add setBaseUrl to your bootstrap file.<?phpclass Bootstrap extends Zend_Application_Bootstrap_Bootstrap{ protected function _initSomeFancyName() { $this->bootstrap('frontController'); $frontController = Zend_Controller_Front::getInstance(); $frontController->setBaseUrl('/myproject'); // set the base url! }}The nginx rewrite would look like this:location /myproject/ { if (!-e $request_filename) { rewrite ^/myproject/(.*)$ /index.php?$1? last; }}PS The question mark is not typo!

posted date: 2009-03-22 18:20:00


Re: Zend Framework on nginx#9
@gaoshan88 If stunti answered, why not accept his answer or is there anything else we can help you with?

posted date: 2009-05-04 08:51:00


Re: Zend Framework on nginx#10
Because, at the time, I had not had a chance to actually test stunti's suggestion.

posted date: 2009-11-21 21:36:00


Re: Zend Framework on nginx#11
Defeats the point of Nginx though, which is speed.

posted date: 2010-01-21 15:29:00


Re: Zend Framework on nginx#12
For staging server that could help ;) fastcgi_param APPLICATION_ENV staging;

posted date: 2010-10-26 07:24:00


select page: « 1 2...»
Copyright ©2008-2017 www.momige.com, all rights reserved.