# Configuring phpmyadmin

**URL:** <https://www.ruby-forum.com/t/configuring-phpmyadmin/207370>\
**Category:** NGINX\
**Created:** [May 24, 2011, 9:26pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370 "2011-05-24T21:26:09Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 24, 2011, 9:26pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/1 "2011-05-24T21:26:09Z")

</div>

Hi,

I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin  
When I go to ‘[http://localhost](http://localhost)’ phpmyadmin pops up.  
What I want is that phpmyadmin is located at  
‘[http://localhost/phpmyadmin/](http://localhost/phpmyadmin/)’

I already tried to add this in nginx.conf. It didn’t work

location /phpmyadmin {  
alias /usr/share/phpmyadmin/;  
}

This is what my nginx.conf looks like:

* * *

user www-data;  
worker\_processes 1;

error\_log /var/log/nginx/error.log;  
pid /var/run/nginx.pid;

events {  
worker\_connections 1024;  
# multi\_accept on;  
}

http {  
include /etc/nginx/mime.types;

```
access_log /var/log/nginx/access.log;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

```

}

* * *

Can anybody help me configuring this the right way?

Posted at Nginx Forum:

> **[Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200488#msg-200488)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 1:16am UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/2 "2011-05-25T01:16:11Z")

</div>

Post your /etc/nginx/sites-enabled/ files and also, keeping phpmyadmin  
on a public directory is bad since bots / scripts automatically scan  
for that in URLs. Restrict it with .htaccess if you want to keep  
phpmyadmin as the directory name or change it to something like  
“fuzzykittens” to hide it.

On 5/24/11, Trazzt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> alias /usr/share/phpmyadmin/;
> 
> ```
> sendfile on;
> include /etc/nginx/sites-enabled/*;
> 
> ```
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
–C

“The dumber people think you are, the more surprised they’re going to  
be when you kill them.” - Sir William Clayton

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 11:41am UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/3 "2011-05-25T11:41:56Z")

</div>

Okay thx for the tip I’m new to this 😉  
Here it is:

phpmyadmin:

* * *

server{  
listen 80;  
server\_name phpmyadmin;  
access\_log /var/log/phpmyadmin.access\_log;  
error\_log /var/log/phpmyadmin.error\_log;

```
location / {
  root /usr/share/phpmyadmin;
  index index.php;
}

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME

```

/usr/share/phpmyadmin$fastcgi\_script\_name;  
include fastcgi\_params;  
}  
}

* * *

This is my fastcgi\_script, located at “/etc/init.d/php-fastcgi”  
[http://pastie.org/1970419](http://pastie.org/1970419)

I also have one other site enabled, I don’t know if thats relevant but  
you can find it here.  
I want this site to be located at ‘localhost’  
[http://pastie.org/1970411](http://pastie.org/1970411)

Posted at Nginx Forum:

> **[Re: Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200656#msg-200656)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 11:46am UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/4 "2011-05-25T11:46:15Z")

</div>

On Wed, May 25, 2011 at 05:41:14AM -0400, Trazzt wrote:

> ```
> include fastcgi_params;
> 
> ```
> 
> I want this site to be located at ‘localhost’  
> [http://pastie.org/1970411](http://pastie.org/1970411)

You probably need

```
location / {
    return 404;
}

location /phpmyadmin {
  root /usr/share;
  index index.php;
}

location ~ ^/phpmyadmin/\.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
    include fastcgi_params;
}

```

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 12:14pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/5 "2011-05-25T12:14:07Z")

</div>

Thank you, that did the trick!  
Only I have a new problem now. PHP looks suddenly disabled  
I get a text file, when I visit: ‘127.0.0.1/phpmyadmin’  
Like this:  
[http://postimage.org/image/2j6o8olyc/](http://postimage.org/image/2j6o8olyc/)

I already tried to add the line:  
fastcgi\_index index.php;  
and restarting nginx. That didn’t work  
Rebooting also didn’t help

Do you know how I can enable PHP again?

Posted at Nginx Forum:

> **[Re: Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200667#msg-200667)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 12:25pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/6 "2011-05-25T12:25:55Z")

</div>

On Wed, May 25, 2011 at 06:13:49AM -0400, Trazzt wrote:

> Thank you, that did the trick!  
> Only I have a new problem now. PHP looks suddenly disabled  
> I get a text file, when I visit: ‘127.0.0.1/phpmyadmin’  
> Like this:  
> [http://postimage.org/image/2j6o8olyc/](http://postimage.org/image/2j6o8olyc/)
> 
> I already tried to add the line:  
> fastcgi\_index index.php;  
> and restarting nginx. That didn’t work

You do not need this directive.

> Rebooting also didn’t help
> 
> Do you know how I can enable PHP again?

- location ~ ^/phpmyadmin/.php$ {

- location ~ ^/phpmyadmin/.+.php$ {

This is yet one of the reasons why I try to avoid as much as possible  
regex locations - too high mistake probability if you do not write or  
read  
a hundrend regexes a day.

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 2:05pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/7 "2011-05-25T14:05:33Z")

</div>

On 05/25/11 12:58, Trazzt wrote:

> I really appreciate your help, but PHP is still not working  
> This is how my phpmyadmin configuration file looks like after all your  
> edits:

> ```
> location ~ ^/phpmyadmin/.+\.php$ {
> fastcgi_pass 127.0.0.1:9000;
> fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
> include fastcgi_params;
> 
> ```

I found I had to use:

fastcgi\_param SCRIPT\_FILENAME $request\_filename;

I don’t really understand why.

Dick

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 2:49pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/8 "2011-05-25T14:49:33Z")

</div>

On Wed, May 25, 2011 at 01:04:44PM +0100, Dick M. wrote:

> I found I had to use:
> 
> fastcgi\_param SCRIPT\_FILENAME $request\_filename;
> 
> I don’t really understand why.

$request\_filename is “$document\_root$uri”.

–

[http://sysoev.ru](http://sysoev.ru)

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 2:50pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/9 "2011-05-25T14:50:47Z")

</div>

On Wed, May 25, 2011 at 07:58:21AM -0400, Trazzt wrote:

> I really appreciate your help, but PHP is still not working

What does it means - “PHP is still not working” ?

> ```
> return 404;
> include fastcgi_params;
> }
> 
> ```
> 
> }
> 
> * * *

–

[http://sysoev.ru](http://sysoev.ru)

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 1:58pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/10 "2011-05-25T13:58:44Z")

</div>

I really appreciate your help, but PHP is still not working  
This is how my phpmyadmin configuration file looks like after all your  
edits:

* * *

server{  
listen 80;  
server\_name phpmyadmin;  
access\_log /var/log/phpmyadmin.access\_log;  
error\_log /var/log/phpmyadmin.error\_log;

```
location / {
return 404;
  }

location /phpmyadmin {
root /usr/share;
index index.php;
  }

location ~ ^/phpmyadmin/.+\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
include fastcgi_params;
  }

```

}

* * *

Posted at Nginx Forum:

> **[Re: Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200702#msg-200702)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 3:16pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/11 "2011-05-25T15:16:10Z")

</div>

On Wed, May 25, 2011 at 09:07:30AM -0400, Trazzt wrote:

> I mean I still get the text screen like in the image. I still get no  
> layout, only the ‘index.php’ file in text format.  
> Like in the screenshot:  
> [http://postimage.org/image/2j6o8olyc/](http://postimage.org/image/2j6o8olyc/)

Try to add localhost and 127.0.0.1 to ensure that you request a right  
server:

server{  
listen 80;  
server\_name phpmyadmin localhost 127.0.0.1;

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 3:08pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/12 "2011-05-25T15:08:06Z")

</div>

I mean I still get the text screen like in the image. I still get no  
layout, only the ‘index.php’ file in text format.  
Like in the screenshot:  
[http://postimage.org/image/2j6o8olyc/](http://postimage.org/image/2j6o8olyc/)

Posted at Nginx Forum:

> **[Re: Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200733#msg-200733)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 3:35pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/13 "2011-05-25T15:35:21Z")

</div>

I tried what you said, but I still get the text file.

Thanks for all your support, I’m gonna reinstall phpmyadmin completely  
using the configuration files you supplied.

I used this tutorial to install nginx + phpmyadmin, I’ll search for  
another tut.

> **[Howto nginx + php5 + mysql + phpmyadmin + ubuntu shortest setup](https://joneslee85.wordpress.com/2010/02/28/howto-nginx-php5-mysql-phpmyadmin-ubuntu-shortest-setup/)**
>
> The following tutorial is done with Ubuntu Lucid 10.04 on Lenovo Thinkpad X200 laptop. In this tutorial, I will show you the shortest and easiest way to set up nginx up with PHP5, MySQL and phpmyad…

Posted at Nginx Forum:

> **[Re: Configuring phpmyadmin](https://forum.nginx.org/read.php?2,200488,200751#msg-200751)**
>
> Hi, I recently installed Debian 6.0.1a Squeeze with Nginx and phpmyadmin When I go to 'http://localhost' phpmyadmin pops up. What I want is that phpmyadmin is located at 'http://localhost/phpmyadmin/' I already tried to add this in nginx.conf. It...

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 3:37pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/14 "2011-05-25T15:37:12Z")

</div>

On Wed, May 25, 2011 at 09:34:57AM -0400, Trazzt wrote:

> I tried what you said, but I still get the text file.
> 
> Thanks for all your support, I’m gonna reinstall phpmyadmin completely  
> using the configuration files you supplied.
> 
> I used this tutorial to install nginx + phpmyadmin, I’ll search for  
> another tut.

> **[Howto nginx + php5 + mysql + phpmyadmin + ubuntu shortest setup](https://joneslee85.wordpress.com/2010/02/28/howto-nginx-php5-mysql-phpmyadmin-ubuntu-shortest-setup/)**
>
> The following tutorial is done with Ubuntu Lucid 10.04 on Lenovo Thinkpad X200 laptop. In this tutorial, I will show you the shortest and easiest way to set up nginx up with PHP5, MySQL and phpmyad…

Could you create debug log of the request ?

> **[A debugging log](http://nginx.org/en/docs/debugging_log.html)**

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 4:01pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/15 "2011-05-25T16:01:24Z")

</div>

On Wed, May 25, 2011 at 02:56:07PM +0100, Dick M. wrote:

> > ```
> > fastcgi_pass 127.0.0.1:9000;
> > 
> > ```
> 
> ```
> location /phpmyadmin {
> 
> ```
> 
> index index.php;  
> …
> 
> ```
> location ~ \.php$ {
> ...
> }
> }
> 
> ```
> 
> No?

Yes, inclusive “location ~ .php$” is much better than configuration  
I suggested.

However, my configuration should also work, since /phpmyadmin/ is  
internally redirected to /phpmyadmin/index.php, see for details:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 4:39pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/16 "2011-05-25T16:39:44Z")

</div>

## Igor S. Wrote:

> > > ```
> > > listen 80;
> > > root /usr/share;
> > > 
> > > ```
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

I’m trying to explain to you why I can’t debug the file, but the forum  
says  
Possible hack attempt detected. The posted form data was rejected.

I’m having trouble running the “./configure” command, when I try to run  
it in terminal

When I uninstalled nginx, somehow apache2 started, while I never  
installed apache2  
I couldn’t uninstall apache, because only the apache2 service was on my  
pc, and no installation files.

Maybe this is causing the nginx errors.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,200488,200779#msg-200779](http://forum.nginx.org/read.php?2,200488,200779#msg-200779)

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 3:56pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/17 "2011-05-25T15:56:26Z")

</div>

On 05/25/11 12:58, Trazzt wrote:

> ```
> location / {
> fastcgi_param SCRIPT_FILENAME /usr/share$fastcgi_script_name;
> include fastcgi_params;
> }
> 
> ```
> 
> }

I’m not sure which location /phpmyadmin/ is served from. If it’s the  
first, as I suspect, then there’s no way index.php is going to be  
processed.

I would use:

```
 location /phpmyadmin {

```

index index.php;  
…

```
    location ~ \.php$ {
    ...
    }
 }

```

No?

Dick

---

<div class="post-metadata">

**Author:** ![Trazzt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e68b1a/32.png) [@Trazzt](https://www.ruby-forum.com/u/Trazzt)\
**Post date:** [May 25, 2011, 4:42pm UTC](https://www.ruby-forum.com/t/configuring-phpmyadmin/207370/18 "2011-05-25T16:42:50Z")

</div>

> I’m trying to explain to you why I can’t debug the file, but the forum  
> says  
> Possible hack attempt detected. The posted form data was rejected.

The forum is a gateway to mailing list:

> **[mailman.nginx.org archive](http://mailman.nginx.org/pipermail/)**

You may write there.

–  
Igor S.
