.

NGINX 설치 (Apache 또는 Lighttpd)보다 더 나은 - VPS 성경 백금 11

English 영어 (변경)
  • Digg
  • Twitter
  • Technorati
  • del.icio.us
  • Facebook
  • MySpace
  • Reddit
  • StumbleUpon
  • LinkedIn
  • email

설정 관리되지 않는 VPS (4 Newbies) - 파트 11 : Nginx 최대 (아파치보다) 더 나은 웹 서버

설치 Nginx - Nginx 로고

설치 및 Nginx 웹 서버 조정 기본 파일 구조를 구성하는 다음 심볼릭 링크와 vhost 설정 파일이 복사 / 붙여넣기 방법의 적용을받습니다. 그래서 내가 설명해 줄게 CLI와 열어봐.

그래서 우리는 스타 매력을 설치, Nginx ( "엔진 발음 - x"를) 준비가되었습니다. 그런데 왜? 아파치 최고의 웹 서버가 아닌 가요?

아파치 잘 년 동안, 모두 로컬 및 원격 호스트에 봉사 해 왔고 지금도 많은 대형 사이트에 대한 바람직한 선택입니다.

하지만, 우분투, 파이어 폭스와 jQuery 같은 경우네, 거기에 마을에 새로 온 아이가, 그리고, 구성 및 사용하여 간단하게 적어과 봉사 빨라집니다. Nginx 웹 서버를 입력합니다.

설정 관리되지 않는 VPS (4 Newbies) .. 최대 VPS 성경

20 복사 있음 / 붙여넣기 단계 .. 제로의 영웅에서 빈 상자를 리눅스 서버 귀여운 -했다.

아래로 스크롤하여 전체 시리즈의 색인을 생성합니다.

그럼, 헤이, & 만세! 희망 가상 공유 창고에 도움이됩니다. the_guv

비디오 : & 서버 구성 Nginx 웹 설치

이렇게하는 방법의 더 나은 아이디어를보고, 어, guvideo.

체크 http://youtube.com/guvnrDOTcom에서 the_guv의 YouTube 채널

아니면 만약 네가 그렇게한다면, 또는 심지어 수 있으면, 여기 사소 한거와 귀찮게 할 수 없지 ...

왜 Nginx를 선택해야 하나요? 왜 Apache 또는 Lighttpd?

난 전문가가되어야 할 사람 공언 울트라 연구, 누군가를 철저하게. 나는 두 가지 가장 최상의 약 geekdom 모든 aflutter이 웹 서버, 아파치와 Lighttpd, 그리고 젊은 터크 대안, Nginx, 설립의 인기는 주로 밀집되어있습니다. 여기 내 주요 연구 결과의 요약입니다 : -

  • 아파치, 사용하지 않는 모듈을 로딩 bloatware입니다 폐기물 자원
  • Lighttpd 누수가 RAM이 심하게
  • Nginx 벤치 마크에서 가장 빠른, 적어도 리소스를 사용

내 리소스에 대한이 가벼운 무게 서버를 사용하고 있는데, 무거운 WordPress의 블로그 guvnr.com, 그리고 안정적인 성능과 감동입니다. 또한 중요한 것은, 그것을하지 않는 경향이 같은 윈도우, 아파치 고통도, 난 그냥 필요하지 않은 서비스들을 실행하여 자원을 낭비했다.

그건 내 말을 오해하지 마십시오. 당신이해야하지, 왜냐하면 어떤 벤치 마크 테스트를 수행하지 않았습니다. 아파치와 같은 Google 뭔가 Nginx "또는 Nginx Lighttpd 비교읽었를 말합니다. 그리고 여기 Nginx 위키이야.

Nginx 최신 버전 받기

이미 리눅스에서 소프트웨어를 설치하는 두 가지 방법으로, 통합 설치 도구 또는 소스 코드에서 사용하고있습니다.

일반적으로, 우리는 내부적으로, 리눅스 설치 '적성', 왜냐하면 이것이 우리의 VPS 같은 중요한 구성 요소입니다, 제가 소스로부터 설치하는 방법을 보여줄 것처럼 뭔가를 사용하여 설치합니다. 이 방법은 좀 더 걸립니다, 왜냐하면 우리가 훨씬 더 많을 테니 최신 버전의 그게 그만한 가치가 있어요.

.. 웹 서버와, 우리는 모서리 잘라 안됩니다. 그 노란 페라리를 구입과 같은 것입니다.

우선, 우리는 몇 가지 종속 파일이 필요합니다 : -

sudo aptitude -y install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

And to create a directory in which to store the Nginx package:-

mkdir ~/sources

Change to that directory:-

cd ~/sources/

Now we get the latest stable Nginx release, nginx-0.7.62 *.

* As of September 2009, edited by the_guv. You should still check it is still the latest, here , and ammend the filename accordingly:-

wget http://sysoev.ru/nginx/nginx-0.7.62.tar.gz

Unzip it:-

tar -zxvf nginx-0.7.62.tar.gz

Go into the new unzipped folder:-

cd nginx-0.7.62

Installing and Testing Nginx

Compile with two options; where to install it, and including 'ssl' (to enable 'https' for secure connections, ie shopping and stuff):-

./configure --sbin-path=/usr/local/sbin --with-http_ssl_module

Install this baby:-

make
sudo make install

Kick it up:-

sudo /usr/local/sbin/nginx

And test it by popping your IP address in a web browser. You should see "Welcome to nginx!"

Now stop it:-

sudo kill `cat /usr/local/nginx/logs/nginx.pid`

Have Nginx Start, Restart or Stop When Required

This is important, for example, upon reboot. We need a script for this. Create a file:-

sudo nano /etc/init.d/nginx

And paste this within:-

#! /bin/sh

### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO

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

Then give the file permissions and make the script run on reboot, else start/stop/restart when required:-

sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults

nginx.conf - Configuring Nginx

Now open the Nginx configuration file:-

sudo nano /usr/local/nginx/conf/nginx.conf

...and strip out all the content, delete the lot. CTRL-K is the easy way to do that, if you were wondering.

And replace with this:-

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/*;
}

Creating the Virtual Host File Structure & Symlinks

The Nginx file structure is pretty messy for multiple sites, so we'll sort that.

First, layout some new folders:-

sudo mkdir /usr/local/nginx/sites-available
sudo mkdir /usr/local/nginx/sites-enabled

...the first is for our virtual host (vhost) files, the second for their corresponding symlinks which will be referenced by Nginx' config file.

What are vhosts & symlinks?

You have one of each per domain, and one of each for the default settings.

The symlink, or symbolic link, references the web server to the virtual host file.

The vhost file is a configuration file. It tells the web server, for example, things like where the web files live or the kind of URI structure you want.

For now, we need a default vhost file, and that goes in the sites-available folder. So:-

sudo nano /usr/local/nginx/sites-available/default

Now paste this:-

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;
            		   }
		}

And enable it with this symlink:-

sudo ln -s /usr/local/nginx/sites-available/default /usr/local/nginx/sites-enabled/default

Boot it up again:-

sudo /etc/init.d/nginx start

...and check for that "Welcome..." page again, using your IP in a web browser.

Splendid. All pretty. And pretty well organised.

Moving Along

So that's Nginx up and running.

In Part 12 of this series Set Up an Unmanaged VPS (4 Newbies) I'm taking a quick detour, setting up FileZilla so we've got a Secure FTP (SFTP) connection. That'll be handy to help demonstrate Part 13, when we create another folder structure, this time for our sites and blogs, and pop up a couple of test pages.

Then, in Part 13, I'll show you how to use Subversion to more easily install and upgrade platforms and their modules/plugins. I'll example the popular WordPress scenario - and while we're about it we'll sort out WordPress caching and friendly-URLs.

And then, this, that, the other. Cue index ..


SETUP an Unmanaged VPS (4 Newbies) .. The V-P-S Bible

Serve multi sites & blogs on a budget .. at the fastest possible speed .. with the least downtime .. in the most secure environment .. and future-proofed for easy admin.

That's what the VPS Bible is about, stepped out in simple copy & paste guides.

From high traffic WordPress blogs to startup web hosts, here's what you need.

Set it up?   Click here for the 21 part follow-up .. V-P-S Admin

  1. * Includes video tutorial.

  2. Not linked = not published. Won't be long. Fix a feed for updates.


If you liked that ...
... maybe you'll like these?

.