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

Nginx conf for phpredmin #62

Open
psokolov opened this issue Dec 24, 2014 · 12 comments
Open

Nginx conf for phpredmin #62

psokolov opened this issue Dec 24, 2014 · 12 comments

Comments

@psokolov
Copy link

Hi, thank You for admin panel! Could you post the configs for Nginx, router.php is not simple to fix the rewrite location rules. URLs look like /index.php/welcome/index/0/0 and so by default script_name is /index.php/welcome/index/0/0. What is the reason to use such complicated URIs?

@devoto13
Copy link

This config posted by author works for me. Hope it helps.

@sasanrose
Copy link
Owner

@psokolov Does the problem still exist?

@Sorcysama
Copy link

Hi, I still have a problem with my nginx setup.

Can you please tell me the rewrite I have to setup ?

Urls are like : index.php / Action_Name / info / 0 / 0 ? param = ...

thanks

@CybotTM
Copy link

CybotTM commented Sep 3, 2015

i have the same problem

@matinfo
Copy link

matinfo commented Sep 12, 2015

Here a idea (ongoing progress) nginx conf setup inside a already php-fpm server to serve at www.mydomain.com/phpredmin that worked for me:

## PHP Redis monitor
location ~ ^/phpredmin/(.+\.php.*)$ {

      alias /var/www/phpredmin/public/$1;

      index  index.html index.php;
      try_files $uri $uri/ /index.php?$args;

      location ~ ^/phpredmin/.+\.(js|css|png|jpg|gif|bmp|swf|ico|pdf|mov|fla|mp4|3gp|zip|rar|7z)$ {
          try_files $uri = 404;
          access_log off;
          expires 24h;
          alias /var/www/phpredmin/public/$1;
      }

      location ~ ^/phpredmin/.+\.php.*$ {
          fastcgi_split_path_info ^(.+\.php)(/.+)$;

          set $fsn /index.php;
          if (-f $document_root$fastcgi_script_name){
             set $fsn $fastcgi_script_name;
          }

          # php5-fpm:
          fastcgi_pass unix:/var/run/phpfpm-xyz.sock;
          include fastcgi_params;
          fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
          fastcgi_param  PATH_INFO        $fastcgi_path_info;
          fastcgi_param  PATH_TRANSLATED  $document_root$fsn;
      }
 }

@CybotTM
Copy link

CybotTM commented Sep 16, 2015

my solution is just replacing try_files $uri =404;
with try_files $fastcgi_script_name =404;

or you drop try_files at all, or only the =404 part as @matinfo did.

@matinfo
Copy link

matinfo commented Oct 17, 2015

Finally here my nginx config that work well to serve http://www.mydomain.com/phpredmin/
(note: the / at the end mandatory):

server  {
    name www.mydomain.com;
    ...

    ## PHP Redis monitor
    location /phpredmin {
        index  index.php;
        root /var/www/phpredmin;

        try_files $uri $uri/ /index.php?$args;

        location ~ ^/phpredmin/.+\.php {

            fastcgi_split_path_info ^(.+\.php)(/.+)$;

            set $fsn /index.php;
            if (-f $document_root$fastcgi_script_name) {
                set $fsn $fastcgi_script_name;
            }

            # php5-fpm
            fastcgi_pass unix:/var/tmp/phpfpm.sock;
            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fsn;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fsn;

            include fastcgi_params;
        }

        location ~ ^/phpredmin/(.+\.(js|css|png|jpg|gif|ico))$ {
            access_log off;
            expires 24h;
            root /var/www/phpredmin;

            try_files $uri =404;
        }
    }
}

Notice: to work the public directory need symlinked to phpredmin, like this:

  • cd /var/www/phpredmin (here the cloned project repository)
  • /var/www/phpredmin$ ln -s public phpredmin

@gabrielwinnberg
Copy link

Is this really necessary? I mean unless you really want a different url than www.example.com/phpredmin/public/index.php ?

I just threw it into the web root (as per the installation instruction) and it seems to work. Or what am I missing?

@iFedix
Copy link

iFedix commented Jun 14, 2017

@matinfo hey i tried your script and it worked.. now, how can i modify it in in order that the application answers me when i digit www.mydomain.com instead of http://www.mydomain.com/phpredmin/?
Thank you!

@matinfo
Copy link

matinfo commented Jun 14, 2017

@iFedix not sur with the project structure of phpredmin is possible.

Workaround add permanent redirection from / to /phpredmin.

rewrite ^(.*) http://www.domain.com/phpredmin/$1 permanent;

--

Or copy content of /public to /var/www/phpredmin and change some location like $path = '../' in index.php to $path = '.'. Plus change location /phpredmin to location /.

Not tested!

@iFedix
Copy link

iFedix commented Jun 15, 2017

@matinfo thank you! :D

@gabrielt
Copy link

gabrielt commented May 1, 2019

What a mess! it took me a couple of hours to get this configured in ngninx... It makes no sense this piece of software to require so much configuration.

Anyway, @matinfo solution worked, but I had to remove the last bracket (location ~ ^/phpredmin/(.+.(js|css|png|jpg|gif|ico))$), otherwise CSS files wouldn't load.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants