Results 1 to 7 of 7
  1. #1

    Exclamation nginx virtual host (server blocks) help needed!

    hello everyone, i really need help with this problem i can't manage to solve.

    i am trying to get "name based virtual host" to work, but i cant find a answer anywhere on the mighty web.

    first i tried apache, but some google results pointed out that apache 2.4 does not have that support anymore (i found that after a few hours of trial and error )

    now i tried nginx, but that doesn't work either.

    what i am attempting to get:

    queztech.net and peppertown.nl both have a A record to the same IP, but i set it up in /etc/nginx/sites-avaiable/default to have a different document root for each, but somehow i ALWAYS end up with the queztech.net document root.

    this is currently my /etc/nginx/sites-available/default content:

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    server {
    listen 80; ## listen for ipv4; this line is default and implied
    #listen [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name queztech.net;
    }

    server {
    listen 80; ## listen for ipv4; this line is default and implied
    #listen [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/peppertown;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    server_name peppertown.nl;
    }
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


    yes, i did restart plenty of times, and i used a bunch of different tutorials, the config from above is from this tutorial: https://www.digitalocean.com/communi...u-12-04-lts--3



    i hope someone can help me, i really need help on this, i can't get it to work, and i did enough attempts at trial-and-error

  2. #2
    Did you make symbolic links and have you executed: "sudo rm /etc/nginx/sites-enabled/default" ?

  3. #3
    Join Date
    Feb 2012
    Posts
    238
    This is a really nice guide to help you setup virtual hosts in nginx:
    https://www.digitalocean.com/communi...u-12-04-lts--3

    Good Luck.
    WEBUZO - Single User Control Panel for your VPS/Cloud/Server (CentOS/Ubuntu)
    Install NGINX, Apache, MySQL, LAMP, LEMP, PHP, Java and 310+ popular scripts by a CLICK
    Email Server, Database Management, Domain Management, FTP Management, CSF, CRON

  4. #4
    this is the default file

  5. #5
    Join Date
    Oct 2009
    Posts
    856
    Did you actually include the files in nginx.conf? As in,

    include /etc/nginx/sites-enabled/*;

    or similar?

  6. #6
    Join Date
    Mar 2008
    Location
    Rajapalayam, TN, India
    Posts
    1

    What error did you get?

    The issue is in 'default' that can only be mentioned in one server block. Currently, it is mentioned in both the sites.

    A few questions:

    Can you start the Nginx server? If you can't, please post what error you see.

    Typing `nginx -t` helps to figure out any syntax errors. Did you try it?

    If Nginx starts okay, then what else is not working?

  7. #7
    Why don't you make 2 conf, one for each site, you will have 3 configs total in /etc/nginx/sites-enabled/ :

    1. /etc/nginx/sites-enabled/default
    2. /etc/nginx/sites-enabled/queztech.net
    3. /etc/nginx/sites-enabled/peppertown.nl

    first try to use default that you had after nginx install uncomment all new lines you added, and for 2 and 3 conf you can use something like this:

    Code:
    server {
            listen   80;
            root /var/www/queztech.net/;
            index index.html index.htm index.php;
    
            server_name queztech.net;
    
            location / {
                            try_files $uri $uri/ /index.html;
            }
    
            location ~ \.php$ {
                            fastcgi_pass unix:/var/run/php5-fpm.sock;
                            fastcgi_index index.php;
                            include fastcgi_params;
            }
    }
    just change domain name for 3rd config and restart nginx

    Code:
    service nginx restart
    and one more thing I saw you use /var/peppertown.nl as your root for second site have you changed permissions for that directory? Better move that to /var/www/peppertown.nl.

    Hope this helps!!!

Similar Threads

  1. ionCube loader problem in create virtual host of nginx
    By WELT SERVER in forum Dedicated Server
    Replies: 3
    Last Post: 07-31-2013, 06:21 AM
  2. Replies: 10
    Last Post: 01-26-2013, 08:49 AM
  3. Replies: 16
    Last Post: 08-04-2011, 02:41 PM
  4. Virtual host needed
    By Desperate in forum Web Hosting
    Replies: 3
    Last Post: 12-10-2001, 07:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •