Activity Stream
48,167 MEMBERS
6802 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 9 of 9
  1.     
    #1
    Member

    Default Nginx on Linux VPS - Newbie Freindy, the Complete Guide

    Hey guys,

    This is my first tutorial. I was just browsing ‘Tutorials and Guides’ section and noticed few Nginx related tutorials. But none of them were complete tutorials. I mean installing Nginx is just a piece of big pie. You need to prepare your Linux for it. And after installation, what should you do? Can you install a WordPress or PHP base applications? Well, you can try your luck.

    So I don’t have time to write all this. I have it covered on my blog ‘Step-by-Step Guide to WordPress on Nginx Server’. What I’m going to do here is, tell you the proper way of installing latest version of Nginx on an Ubuntu VPS. All additional details and background can be found at above mentioned post. And remember this is just a one part of many.

    I need latest version of Nignx. So I won’t mess with integrated packages. I’ll install it from source. So we need to collect some dependency files. Below code will do it,

    Code: 
    sudo aptitude -y install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
    We need a folder inside our Ubuntu box to download installation files. Let’s create it,

    Code: 
    mkdir ~/sources
    cd ~/sources/
    We’ll use ‘wget’ to download latest release or Nginx from official site. As for today, latest version is 1.2.0. To make sure you get the latest version, go to this page and find out if it’s still the up to date version. Change the version number accordingly on below code if it’s deferent from official site. Following code will download it.

    Code: 
    wget http://nginx.org/download/nginx-1.2.0.tar.gz
    Extract it,
    Code: 
    tar -zxvf nginx-1.0.12.tar.gz
    Navigate to extracted folder,
    Code: 
    cd nginx-1.0.12
    Now configure it. Note that code at the end. ‘--with-http_ssl_module’ it’s for SSL support. You probably don’t need it unless you have a SSL license. Just remove it.
    Code: 
    ./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
    Below command will install Nginx on your Ubuntu box.
    Code: 
    make
    sudo make install
    Now fire it up,
    Code: 
    sudo /usr/local/sbin/nginx
    That’s it. Open your ip in browser and it should say ‘Welcome to nginx!’
    That’s it right? No not exactly.
    Nginx won’t auto start on reboots. So let’s make it happen.
    First kill Nginx,
    Code: 
    sudo kill `cat /usr/local/nginx/logs/nginx.pid`
    We’ll create a script to do it. So create a new file,
    Code: 
    sudo nano /etc/init.d/nginx
    Paste this lot to new file,
    Code: 
    #! /bin/sh
    
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/sbin/nginx
    NAME=nginx
    DESC=nginx
    
    test -x $DAEMON || exit 0
    
    # Include nginx defaults if available
    if [ -f /etc/default/nginx ] ; then
            . /etc/default/nginx
    fi
    
    set -e
    
    case "$1" in
      start)
            echo -n "Starting $DESC: "
            start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid
                    --exec $DAEMON -- $DAEMON_OPTS
            echo "$NAME."
            ;;
      stop)
            echo -n "Stopping $DESC: "
            start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid
                    --exec $DAEMON
            echo "$NAME."
            ;;
    
      restart|force-reload)
            echo -n "Restarting $DESC: "
            start-stop-daemon --stop --quiet --pidfile
                    /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
            sleep 1
            start-stop-daemon --start --quiet --pidfile
                    /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
            echo "$NAME."
            ;;
      reload)
          echo -n "Reloading $DESC configuration: "
          start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid
              --exec $DAEMON
          echo "$NAME."
          ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
            exit 1
            ;;
    esac
    
    exit 0
    Give permissions to it,
    Code: 
    sudo chmod +x /etc/init.d/nginx
    sudo /usr/sbin/update-rc.d -f nginx defaults
    Let’s tell Nginx how it should be working on our box. Open Nginx configuration file,
    Code: 
    sudo nano /usr/local/nginx/conf/nginx.conf
    Delete everything on that file and paste following,

    Code: 
    user www-data www-data;
    worker_processes  4;
    
    events {
        worker_connections  1024;
    }
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        sendfile        on;
        tcp_nopush      on;
        tcp_nodelay     off;
        keepalive_timeout  5;
    
        gzip  on;
        gzip_comp_level 2;
        gzip_proxied any;
        gzip_types      text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    
        include /usr/local/nginx/sites-enabled/*;
    }
    Save and close.
    Let’s create Virtual Host File Structure & Symlinks,
    We need 2 new folders
    Code: 
    sudo mkdir /usr/local/nginx/sites-available
    sudo mkdir /usr/local/nginx/sites-enabled
    Create default default vhost file,
    Code: 
    sudo nano /usr/local/nginx/sites-available/default
    And paste default rules into it,
    Code: 
    server  {
                listen       80;
                server_name  localhost;
    
                location /  {
                        root   html;
                        index  index.php index.html index.htm;
                          }
    
                # redirect server error pages to the static page /50x.html
                error_page   500 502 503 504  /50x.html;
                location = /50x.html
                           {
                            root   html;
                           }
            }
    Enable vhost
    Code: 
    sudo ln -s /usr/local/nginx/sites-available/default /usr/local/nginx/sites-enabled/default
    Restart Nginx
    Code: 
    sudo /etc/init.d/nginx start
    Check your ip again. It should still say ‘Welcome to Nginx!’

    That’s it! Nginx is now working properly. Remember this is 5th post of my Nginx series. All other tutorials are available at my blog.
    Source - Install and Configure Nginx Web Server on Ubuntu VPS
    Freddy63 Reviewed by Freddy63 on . Nginx on Linux VPS - Newbie Freindy, the Complete Guide Hey guys, This is my first tutorial. I was just browsing ‘Tutorials and Guides’ section and noticed few Nginx related tutorials. But none of them were complete tutorials. I mean installing Nginx is just a piece of big pie. You need to prepare your Linux for it. And after installation, what should you do? Can you install a WordPress or PHP base applications? Well, you can try your luck. So I don’t have time to write all this. I have it covered on my blog ‘Step-by-Step Guide to WordPress on Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Thanks dude, adding screen shots much appreciated

    PS: what is the best ubuntu version?

  4.     
    #3
    Banned
    Website's:
    xsl.tel xsltel.com
    hmmm

    I can't see any difference from other nginx tutorials except the version you downloaded is the newest one.

    and of course all tutorials don't mention how to setup nginx to deal with php files through 3rd party fastcgi application.

  5.     
    #4
    Member
    Thanks. Will prolly use this in the future.

  6.     
    #5
    Member
    Quote Originally Posted by tut2tut View Post
    Thanks dude, adding screen shots much appreciated

    PS: what is the best ubuntu version?
    This was tested on Ubuntu 10.04 LTS and Ubuntu 11.04 LTS. But it should work with anything after 10.04 LTS. I always prefer LTS versions

  7.     
    #6
    Member
    Can you make this tut for CentOS ? It looks perfect.

  8.     
    #7
    Banned
    how to use this Nginx in to kloxo with centos os
    please complete guide

  9.     
    #8
    Member
    Website's:
    texasinvest.com forexgiant.biz
    Can you make one for centOS please!

  10.     
    #9
    Member
    yeah, nginx the best work like a harm .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 12
    Last Post: 23rd Jan 2012, 10:21 AM
  2. Complete DVD Ripping Guide Using Handbrake (Easy to Use n Rip)
    By Faizann20 in forum Tutorials and Guides
    Replies: 10
    Last Post: 10th Jan 2012, 12:45 AM
  3. [Tutorial] Complete Guide to IDM | How to Setup IDM
    By BAD BOY in forum Tutorials and Guides
    Replies: 7
    Last Post: 30th Sep 2010, 08:01 AM
  4. Torrents - A complete Guide.
    By lakshyak in forum Tutorials and Guides
    Replies: 1
    Last Post: 20th Jan 2008, 08:54 AM

Tags for this Thread

BE SOCIAL