Nginx adding locations

Hi, i've installed Nginx on my linode on ubuntu…

i have a domain name and i am hosting a site.

But i also want to have some separate sites for testing, sites for which i don't have a domain name, so my question is:

Can i have sites that can be accessed like "myipaddress/mytestsite"?

like i did in apache where i could host sites in localhost/mysite1 and have access to them from anywhere replacing "localhost" with my ip address.

I've been trying to do so by adding a new location to sites-enabled/default but nothing happened.

Thank you

10 Replies

Just use servername "" (or don't put a servername line at all).

thanx i'll try that out, but why it doesn't work the way /phpmyadmin works?

to make that work i just had to add the following to a file in sites-enabled

location /phpmyadmin {

root /usr/share/;

index index.php index.html index.htm;

location ~ ^/phpmyadmin/(.+.php)$ {

try_files $uri =404;

root /usr/share/;


fastcgi_index index.php;

fastcgiparam SCRIPTFILENAME $documentroot$fastcgiscript_name;

include /etc/nginx/fastcgi_params;


location ~* ^/phpmyadmin/(.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {

root /usr/share/;



Do you have php-fpm running and listening on port 9000?

Are you sure the files for phpMyAdmin are in /usr/share/ (I'd guess they're a bit deeper than that)?

Does the user running php-fpm have access to those files?

you are right, the root for phpmyadmin would be /usr/share/phpmyadmin/

But that is working fine..

How can i check how's php-fpm is working?

Also, where should i put the server_name ""; ?

in a new file? in default? in the same default server{} block?

Thanks for the help!

In the server block. You can check if php-fpm is working by typing netstat -nl and checking if there is something listening on IPv4 port 9000.

Here it is:

tcp 0 0* LISTEN

here is the first part of my server block in default

i added a new location there /biogas but that is doing nothing…

clueless :?

server {

listen 80 default;

server_name localhost;

server_name "";

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

location / {

root /var/www/nginx-default/;

index index.html index.htm;


location /doc {

root /usr/share;

autoindex on;


deny all;


location /images {

root /usr/share;

autoindex on;


location /biogas {

root /srv/www/biogas/public_html;

autoindex on;


Try removing server_name localhost;

This is what i get when i do that and restart nginx:

Restarting nginx: [emerg]: the first server name must not be empty in /etc/nginx/sites-enabled/default:9

Then give it multiple names, but on the same line:

server_name * "";


server_name localhost "";

Still not working…i'm lost

this should be an easy task, do i have to change something in etc/hosts?


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct