Skip to content
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

Add install/upgrade instructions along with rewrite rules #36

Closed
h9k opened this issue Apr 6, 2012 · 7 comments
Closed

Add install/upgrade instructions along with rewrite rules #36

h9k opened this issue Apr 6, 2012 · 7 comments
Assignees
Milestone

Comments

@h9k
Copy link
Owner

h9k commented Apr 6, 2012

No description provided.

@ghost ghost assigned h9k Apr 6, 2012
@h9k
Copy link
Owner Author

h9k commented Apr 6, 2012

these are contributed for nginx

location ~ ^(/index.php|/admin/index.php|/rest/denora.php) {
        try_files $1 =404;
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass  backend;
        fastcgi_index index.php;
}

@Jyzee
Copy link
Contributor

Jyzee commented Apr 9, 2012

Adding some comments to my contribution up there.

If you install Magirc in a subfolder (document_root/subfolder), you'll need to add that subfolder in the location line :

location ~ ^(<subfolder>/index.php|<subfolder>/admin/index.php|<subfolder>/rest/denora.php) {
    try_files $1 =404;
    include /etc/nginx/fastcgi.conf;
    fastcgi_pass  backend;` 
    fastcgi_index index.php;
}

For example, if you install Magirc in a magirc subfolder, that gives you :

location ~ ^(/magirc/index.php|/magirc/admin/index.php|/magirc/rest/denora.php) {
    try_files $1 =404;
    include /etc/nginx/fastcgi.conf;
    fastcgi_pass  backend;` 
    fastcgi_index index.php;
}

You also have to replace fastcgi_pass backend; by your actual backend for this to work.

@h9k
Copy link
Owner Author

h9k commented Apr 12, 2012

This is actually "stolen" from the Slim README.md
We can leave the Apache part out since we already have one, however the nginx/lighttpd stuff is interesting... We should adapt those rules to work with index.php, admin/index.php and rest/denora.php

Setup your webserver

Apache

Ensure the .htaccess and index.php files are in the same public-accessible directory. The .htaccess file should contain this code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Nginx

Your nginx configuration file should contain this code (along with other settings you may need) in your location block:

if (!-f $request_filename) {
    rewrite ^ /index.php last;
}

This assumes that Slim's index.php is in the root folder of your project (www root).

lighttpd

Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires lighttpd >= 1.4.24.

url.rewrite-if-not-file = ("^" => "/index.php")

This assumes that Slim's index.php is in the root folder of your project (www root).

@Jyzee
Copy link
Contributor

Jyzee commented Apr 12, 2012

    location / {
            if (!-f $request_filename) {
                    rewrite ^ /index.php last;
            }
    }

    location ~ \.php$ {
            try_files $uri =404;
            include /etc/nginx/fastcgi.conf;
            fastcgi_pass backend;
            fastcgi_index index.php;
            fastcgi_intercept_errors on;
    }

Just tried with those blocks, admin and ajax calls are not working.
/admin/index.php/configuration will be considered as a file by the fastcgi backend, resulting in 404 Not Found because that file doesn't exists and can't be processed.
Maybe I need to tweak a little the fastcgi location block.

@h9k
Copy link
Owner Author

h9k commented Apr 12, 2012

I have absolutely no idea about nginx and lighttps, we just need some rules that work possibly on any system.
Are there any other modes other than fcgi to run php on nginx? Or does everyone use that?

@Jyzee
Copy link
Contributor

Jyzee commented Apr 12, 2012

On Nginx you must use php-cgi or php-fpm. There is no module like Apache's one.
I'm trying to get a full working config that can also handle Magirc rewrite.

@Jyzee
Copy link
Contributor

Jyzee commented Apr 12, 2012

Sorry for double posting.

Here we go for installing Magirc in the document root :

index index.php index.html;
location / {
        try_files $uri $uri/ /index.php;
}

location ~ ^(/.*\.php)(/.*)?$ {
        try_files $1 =404;
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass  backend;
        fastcgi_index index.php;
       #fastcgi_intercept_errors on;
}

And this is for a directory in document_root (document_root/magirc_directory) :

index index.php index.html;
location /magirc_directory {
        try_files $uri $uri/ /magirc_directory/index.php;
}

location ~ ^(/magirc_directory/.*\.php)(/.*)?$ {
        try_files $1 =404;
        include /etc/nginx/fastcgi.conf;
        fastcgi_pass  backend;
        fastcgi_index index.php;
       #fastcgi_intercept_errors on;
}

This will work with or without Magirc rewrite.
Comment out fastcgi_intercept_errors on; to override Magirc 404 blue pages.
Don't forget to replace fastcgi_pass backend; by your actual backend.

@h9k h9k closed this as completed in 98c9bc3 Apr 20, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants