Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Nginx adding locations
PostPosted: Fri Mar 23, 2012 12:51 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
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


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 12:59 pm 
Offline
Senior Newbie

Joined: Thu Oct 20, 2011 2:16 am
Posts: 7
Just use server_name "" (or don't put a server_name line at all).


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:09 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
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_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:24 pm 
Offline
Senior Newbie

Joined: Thu Oct 20, 2011 2:16 am
Posts: 7
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?


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:37 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
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!


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:39 pm 
Offline
Senior Newbie

Joined: Thu Oct 20, 2011 2:16 am
Posts: 7
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.


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:49 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
Here it is:
tcp 0 0 127.0.0.1:9000 0.0.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;
allow 127.0.0.1;
deny all;
}

location /images {
root /usr/share;
autoindex on;
}

location /biogas {
root /srv/www/biogas/public_html;
autoindex on;
}


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 1:58 pm 
Offline
Senior Newbie

Joined: Thu Oct 20, 2011 2:16 am
Posts: 7
Try removing server_name localhost;


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 2:18 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
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


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 2:29 pm 
Offline
Senior Newbie

Joined: Thu Oct 20, 2011 2:16 am
Posts: 7
Then give it multiple names, but on the same line:

server_name mydomainname.com *.mydomainname.com "";

or

server_name localhost "";


Top
   
 Post subject:
PostPosted: Fri Mar 23, 2012 10:34 pm 
Offline
Senior Newbie

Joined: Fri Mar 23, 2012 12:26 pm
Posts: 6
Location: Argentina
Still not working...i'm lost
this should be an easy task, do i have to change something in etc/hosts?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group