Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in configuring nginx server-block with subdomains
    primarykey
    data
    text
    <p>I've always used apache for my own vps. Recently I've decided to switch over nginx. I've never used it before, so I'm figuring out some issues in configuring virtual host with subdomains.</p> <p>My vps is running ubuntu 12.04, fresh install with no apache installed.</p> <p>I want to store multiple website inside the folder /usr/share/nginx. Inside this dir I've the following structure:</p> <pre><code>root@mauro-vps:/usr/share/nginx# tree . ├── blog.marano.tk │   └── public_html │   └── index.php └── marano.tk └── public_html └── index.php </code></pre> <p>As you can see I've seted a free domain name (marano.tk) pointing to my vps's ip. And I want to store on this server two websites:</p> <ul> <li>blog.marano.tk</li> <li>marano.tk</li> </ul> <p>Just to understand how nginx works.</p> <p>My <code>/etc/nginx/nginx.conf</code> is the default one, I've edited nothing inside it.</p> <p>Inside <code>/etc/nginx/sites-aviable</code> I've two configuration files (one for each domains):</p> <ul> <li>default (pointing to marano.tk)</li> <li>blog.marano.tk</li> </ul> <p>First file <code>#/etc/nginx/sites-aviable/default</code></p> <pre><code> server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 #root /usr/share/nginx/www; root /usr/share/nginx/marano.tk/public_html; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name marano.tk www.marano.tk; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone fastcgi_pass 127.0.0.1:9000; # With php5-fpm; # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } </code></pre> <p>Second files <code>/etc/nginx/sites-aviable/blog.marano.tk</code></p> <pre><code> server { #listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /usr/share/nginx/blog.marano.tk/public_html; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name blog.marano.tk www.blog.marano.tk; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; deny all; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-cgi alone fastcgi_pass 127.0.0.1:9000; # With php5-fpm; # fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } </code></pre> <p>Then I've symlinked both files:</p> <pre><code>ln -s /etc/nginx/sites-aviable/default /etc/nginx/sites-enabled/ ln -s /etc/nginx/sites-aviable/blog.marano.tk /etc/nginx/sites-enabled/ </code></pre> <p>After restarting nginx and php if I point to <em>blog.marano.tk</em> I still get the content inside <strong>/usr/share/nginx/marano.tk/public_html/index.php</strong> insted of <strong>/usr/share/nginx/blog.marano.tk/public_html/index.php</strong></p> <p>Where I'm going wrong?</p> <p>Sorry for my bad english</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload