Nginx adding locations
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
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;
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/;
}
}
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?
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!
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;
}
Restarting nginx: [emerg]: the first server name must not be empty in /etc/nginx/sites-enabled/default:9
server_name mydomainname.com *.mydomainname.com "";
or
server_name localhost "";
this should be an easy task, do i have to change something in etc/hosts?