-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[documentation] Can anyone help with nginx rewrites? #55
Comments
Hey, just for your info: This script uses the most used htaccess in the world, the typical "beautiful URLs" rewrite rules. No weird stuff, no stunts. I even think Wordpress etc. use exactly the same. Btw maybe Nginx is not what you should use if this brings you in trouble. |
Hi Panique; thanks for your reply. Indeed it does seem to use the standard URL routing, which is why I can't figure out why it isn't working. As for not using Nginx because of the trouble, I'd rather try to find a solution than turn back to Apache, which I detest. I've been using Nginx exclusively since 2010 and it is running phpbb3, Wordpress & phpmyadmin, also CodeIgniter first, then FuelCMS, and now PyroCMS. When I return from work I'll post the full rewrite logs into the nginx and Howtoforge forums to see what they can come up with. Would you mind keeping this open for just one more day, then I can refer back to it, maybe get some more traffic and interest in the project too, and I promise to post any solution here to help others! Thanks. |
He again, can you post more info / error logs ? Btw I noticed that you are using a custom folder structure. The php-mvc is build for usage in webroot or in a simple subfolder, so your use case might be special. The php-mvc is btw made for beginners, I think you're quite professional, maybe you don't need he php-mvc. :) |
I think this ticket is overcomplicating things. The php-mvc is very basic and uses the most standard rewrite rules, and there's no need to install this in nginx in a multi-folder deep nesting structure usually. Running this from two-levels deep subfolders if definitly totally out of the scope of this script, so let's close the ticket. |
Sorry, I have been away for a week, but I have just had a look and by enabling the debug lines, I can quickly see the solution, which is to change rtrim to trim in line 74 of application/libs/application.php. This then makes it compatible with the very popular and fast growing nginx server, without breaking compatibility with Apache. I've contributed the changes and submitted a pull request. The alternative way instead of changing rtrim to trim is the do the following: in the main nginx.conf, eg: /etc/nginx/nginx.conf
then in the server section of the site config file, change
to
You can see which is easier :) Hope this helps others. Thanks. |
Okay this is a often requested feature, let's create a guideline / native integration for this project! Thanks for the comments so far, good stuff in here! |
Hello. I am also having a problem getting this to work on nginx (and switching to Apache is not a realistic option.) I have cloned the repository to /var/www/php-mvc/ when I go to http://XXX.XXX.XXX.XXX/php-mvc/ the homepage shows up perfectly. But, when I click on the links I get a message saying "file not found." I'm not sure how to troubleshoot this. |
Hi @stevehmig - did you try the first, preferred and easier method? Which is: change rtrim to trim in line 74 of application/libs/application.php. in nginx.conf in your location block, put: try_files $uri $uri/ /index.php?url=$uri; and that's it. Just revert those other changes - they are confusing things because at first I could not persuade the author to change rtrim to trim so I had to find a more complicated alternative. If you're still stuck, I'll send you my complete nginx config file :) |
I changed application.php line 74 to trim, I changed my nginx.conf back to the original. I have this in my /etc/nginx/sites-available/default file: |
Sure, @stevehmig - here's my config:
Also, in \php-mvc\application\libs\application.php uncomment the debugging lines at the end so that they look like this:
Doing this REALLY helped me a lot! Also, don't forget to be restarting/reloading your nginx config as the root user - in fact, you can test it first with
|
Thanks, I got it working! I'm not sure if there is a way to get it working my original way, as I have other projects in /var/www/ that I'd want to work on simultaneously. Perhaps this is bad practice, though? Thanks again @digitaltoast |
You SHOULD be able to just change root back to /var/www and the URL define back to how you had it, but you see where it says
Try changing that to
(assuming that you have your php-mvc in that folder, of course! :) |
Awesome stuff! I just made php-mvc work on Mac OS X 10.10 Beta 4 with NGINX 1.6.0, PHP 5.5.14, PEAR 1.9.5 and MySQL 5.6.16. I followed @digitaltoast instructions. Only difference is that I have my sites separated from the main nginx.conf file inside the sites-available folder. Here is my /sites-available/phpmvc.com configuration file:
Added "127.0.0.1 phpmvc.com" to my /etc/hosts file. |
Cool stuff guys! I'll implement this right into the project in September or October (when there's time!). Good to see that the project is useful for you all :) |
FYI: #59 has been just merged into develop branch. |
Heyyyy people, I've just released MINI (=php-mvc) in a new version with a different structure (index.php is now in /public, plus diffrenent .htaccess). Would be nice if you could test this and post a working nginx config for this. Big thanks! |
Great - sounds very exciting! Yes, I'll take a good look and test ASAP, but may not be today. |
Hi @panique - project looks good. It a bit different than I've seen before by having the index file in a subfolder, and may confuse some people used to "index at the top" setups. However, it's not a problem and after a bit of fiddling, this seem to work for very well for me on a "real" server to be sure (not local dev, obviously my hosts file has been changed for this to work)
Short and seet - Anyone else come up with anything better? |
Example nginx config added which can be used as contents of `/etc/nginx/sites-enabled/default`. Closes panique#142 and panique#55.
Good news: There's now a nginx config right in the README :) |
Great looking and educational framework but I'm really struggling here and would appreciate any passing nginxexpers having a look.
I've played with some other basic MVC frameworks and never had the problem where a normal nginx try_file wouldn't work.
So, for example:
But, of course, I can see from the .htaccess and application.php that this uses ?url= GET arguments.
So, 5 hours of reading http://wiki.nginx.org/HttpCoreModule#.24arg_PARAMETER and http://wiki.nginx.org/HttpCoreModule#.24args and http://nginx.org/en/docs/http/converting_rewrite_rules.html I've tried various of the following.... (the install folder is in manage/login
location /manage/login {
try_files $uri $uri/ /manage/login/index.php?url=$uri;
}
also
try_files $uri $uri/ /manage/login/index.php?url=$uri;
try_files $uri $uri/ /manage/login/index.php?url=$args;
try_files $uri $uri/ /manage/login/index.php?url=$uri$args;
try_files $uri $uri/ /manage/login/index.php?$args;
and other combinations of the above. No matter what I put, it always says:
You are in the controller home, using the method index()
You are in the View: application/views/home/index.php
I found another lost soul at http://forum.nginx.org/read.php?2,247614,247647#msg-247647 but again, he wasn't having much luck.
The text was updated successfully, but these errors were encountered: