# Config help needed

**URL:** <https://www.ruby-forum.com/t/config-help-needed/192038>\
**Category:** NGINX\
**Created:** [July 22, 2010, 7:13pm UTC](https://www.ruby-forum.com/t/config-help-needed/192038 "2010-07-22T19:13:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 22, 2010, 7:13pm UTC](https://www.ruby-forum.com/t/config-help-needed/192038/1 "2010-07-22T19:13:22Z")

</div>

Hi all,

I am trying, and failing to set up a server to serve phpmyadmin.

This is my config (one of about 30 tried).

server {  
listen 80 default;  
server\_name default.anake.hcs localhost;  
index index.php index.htm index.html;  
root /var/www/nginx-default/;  
location /doc {  
root /usr/share;  
autoindex on;  
allow 127.0.0.1;  
deny all;  
}  
location /images {  
root /usr/share;  
autoindex on;  
}  
#  
# pass the PHP scripts to FastCGI server listening on  
127.0.0.1:9000  
#  
location ~ .php$ {  
set $php\_root $document\_root;  
if ($request\_uri ~\* /phpmyadmin) {  
set $php\_root /usr/share;  
}  
fastcgi\_param SCRIPT\_FILENAME $php\_root$fastcgi\_script\_name;  
include /etc/nginx/fastcgi.conf;  
fastcgi\_pass 127.0.0.1:9000;  
}  
#  
# phpmyadmin - installed in /usr/share/phpmyadmin/index.php etc  
#  
location /phpmyadmin {  
root /usr/share;  
index index.php;  
}  
}

Results  
/test.php Correct. Properly passes  
/var/www/nginx-default/tesst.php to fast-cgi and displays the results  
/phpmyadmin No input file specified. \*  
\*/phpmyadmin/ No input file specified.  
/phpmyadmin/index.php No input file specified.

I’m using nginx/0.7.67

Help much appreciated

Regards  
Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 22, 2010, 7:40pm UTC](https://www.ruby-forum.com/t/config-help-needed/192038/2 "2010-07-22T19:40:18Z")

</div>

On Fri, Jul 23, 2010 at 12:12 AM, Ian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Â Â Â rootÂ Â /var/www/nginx-default/;  
> Â Â Â #  
> Â Â Â # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
> Â Â Â #  
> Â Â Â location ~ .php$ {  
> Â Â Â Â Â Â fastcgi\_paramÂ SCRIPT\_FILENAMEÂ  
> $document\_root$fastcgi\_script\_name;  
> Â Â Â Â Â Â include /etc/nginx/fastcgi.conf;  
> Â Â Â Â Â Â fastcgi\_passÂ Â 127.0.0.1:9000;  
> Â Â Â }  
> Â Â Â location ~ ^/phpmyadmin/.\*.php$ {  
> Â Â Â Â Â Â Â Â root /usr/share;  
> Â Â Â Â Â Â fastcgi\_paramÂ SCRIPT\_FILENAMEÂ  
> $document\_root$fastcgi\_script\_name;  
> Â Â Â Â Â Â include /etc/nginx/fastcgi.conf;  
> Â Â Â Â Â Â fastcgi\_passÂ Â 127.0.0.1:9000;  
> Â Â Â }  
> Â Â Â #  
> Â Â Â # phpmyadmin - installed in /usr/share/phpmyadmin/index.php etc  
> Â Â Â #  
> #phpmyadmin login page is horribly broken when accessed without  
> extra slash  
> location = /phpmyadmin { rewrite ^ /phpmyadmin/ redirect; }

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 23, 2010, 10:30am UTC](https://www.ruby-forum.com/t/config-help-needed/192038/3 "2010-07-23T10:30:39Z")

</div>

Hi All,

Found what was happening but I don’t know how to fix it.

if I remove the clause starting "location ~ .php$ { " then phpmyadmin  
works.

How can I stop it firing when the URL does NOT contain “phpmyadmin” ???

This is the full config.

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 22, 2010, 9:12pm UTC](https://www.ruby-forum.com/t/config-help-needed/192038/4 "2010-07-22T21:12:15Z")

</div>

Hi Edho,

On 22/07/2010 18:38, Edho P Arief wrote:

A suggestions that I think should have worked, but…

I tried your suggestions - and they had no effect whatsoever.

This is the current, failing, config - copied from a log, so you can see  
exactly what I have

ian@anake:/etc/nginx/sites-enabled$ ls -al  
total 8  
drwxr-xr-x 2 root root 4096 2010-07-22 10:18 .  
drwxr-xr-x 5 root root 4096 2010-06-21 14:36 …  
lrwxrwxrwx 1 root root 38 2010-06-21 14:33 coachmaster -\>  
/etc/nginx/sites-available/coachmaster  
lrwxrwxrwx 1 root root 34 2010-06-21 14:36 default -\>  
/etc/nginx/sites-available/default  
lrwxrwxrwx 1 root root 36 2010-07-22 10:18 SOPSystem -\>  
/etc/nginx/sites-available/SOPSystem  
ian@anake:/etc/nginx/sites-enabled$ cat default

# default server - if no other domain given

# - also handle phpmyadmin

server {  
listen 80 default;  
server\_name default.anake.hcs localhost;  
index index.php index.htm index.html;  
root /var/www/nginx-default/;  
location /doc {  
root /usr/share;  
autoindex on;  
allow 127.0.0.1;  
deny all;  
}  
location /images {  
root /usr/share;  
autoindex on;  
}  
#  
# pass the PHP scripts to FastCGI server listening on  
127.0.0.1:9000  
#  
location ~ .php$ {  
fastcgi\_param SCRIPT\_FILENAME  
$document\_root$fastcgi\_script\_name;  
include /etc/nginx/fastcgi.conf;  
fastcgi\_pass 127.0.0.1:9000;  
}  
#  
# pass phpmyadmin/??? to /usr/share/phpmyadmin/???  
#  
location ~ ^/phpmyadmin/.\*.php$ {  
root /usr/share;  
fastcgi\_param SCRIPT\_FILENAME  
$document\_root$fastcgi\_script\_name;  
include /etc/nginx/fastcgi.conf;  
fastcgi\_pass 127.0.0.1:9000;  
}  
# handle missing /  
location = /phpmyadmin {  
rewrite ^ /phpmyadmin/ redirect;  
}  
location /phpmyadmin/ {  
root /usr/share;  
index index.php;  
}  
}

ian@anake:/etc/nginx/sites-enabled$

All the other sites are listen 80. I’m browsing it from another local  
machine  
via default.anake.hcs daomin name.

ian@anake:/etc/nginx$ cat fastcgi\_params  
#fastcgi\_param SCRIPT\_FILENAME $document\_root$fastcgi\_script\_name;

fastcgi\_param QUERY\_STRING $query\_string;  
fastcgi\_param REQUEST\_METHOD $request\_method;  
fastcgi\_param CONTENT\_TYPE $content\_type;  
fastcgi\_param CONTENT\_LENGTH $content\_length;

fastcgi\_param SCRIPT\_NAME $fastcgi\_script\_name;  
fastcgi\_param REQUEST\_URI $request\_uri;  
fastcgi\_param DOCUMENT\_URI $document\_uri;  
fastcgi\_param DOCUMENT\_ROOT $document\_root;  
fastcgi\_param SERVER\_PROTOCOL $server\_protocol;

fastcgi\_param GATEWAY\_INTERFACE CGI/1.1;  
fastcgi\_param SERVER\_SOFTWARE nginx/$nginx\_version;

fastcgi\_param REMOTE\_ADDR $remote\_addr;  
fastcgi\_param REMOTE\_PORT $remote\_port;  
fastcgi\_param SERVER\_ADDR $server\_addr;  
fastcgi\_param SERVER\_PORT $server\_port;  
fastcgi\_param SERVER\_NAME $server\_name;

fastcgi\_index index.php;

# PHP only, required if PHP was built with --enable-force-cgi-redirect

fastcgi\_param REDIRECT\_STATUS 200;  
ian@anake:/etc/nginx$  
ian@anake:/etc/nginx$ cat nginx.conf  
user www-data www-data;  
worker\_processes 2;

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

events {  
worker\_connections 512;  
}

http {  
include /etc/nginx/mime.types;  
#include /etc/nginx/fastcgi\_params;

```
 default_type application/octet-stream;

 access_log /var/log/nginx/access.log;
 index index.php index.html index.htm;
 sendfile on;
 keepalive_timeout 5;
 tcp_nodelay on;
 gzip on;
 include /etc/nginx/sites-enabled/*[a-zA-Z];

```

}  
ian@anake:/etc/nginx$

To summarise the results  
/ OK - serves index.html  
/test.php OK - passed to fastcgi.  
/phpmyadmin No input file specified. (and the URL  
changes to /phpmyadmin/  
/phpmyadmin/index.php No input file specified.

This config appears to me to be correct, yet it is not working.  
Anyone?

Regards

Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 23, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/config-help-needed/192038/5 "2010-07-23T16:34:50Z")

</div>

On 23/07/2010 10:04, Edho P Arief wrote:

> > 
> 
> move it to bottom

Thanks. Works a treat!

Regards

Ian

---

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [July 23, 2010, 11:48am UTC](https://www.ruby-forum.com/t/config-help-needed/192038/6 "2010-07-23T11:48:31Z")

</div>

On Fri, Jul 23, 2010 at 3:28 PM, Ian H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi All,
> 
> Found what was happening but I don’t know how to fix it.
> 
> if I remove the clause starting Â "location ~ .php$ { " Â then phpmyadmin  
> works.
> 
> How can I stop it firing when the URL does NOT contain “phpmyadmin” ???

move it to bottom

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)
