Please assign a menu to the primary menu location under menu

Nginx

Nginx 설치

1. Nginx 설치 아래 사이트에 방문하셔서 안정 버전 또는 개발자 버전을 다운로드 합니다. (configure 시 의존성 걸리는 라이브러리는 알아서..) http://nginx.org/en/download.html # cd /usr/local/src # wget http://nginx.org/download/nginx-0.8.49.tar.gz # tar xzvf nginx-0.8.49.tar.gz # cd nginx-0.8.49 # touch install.sh # chmod +x install.sh # vi install.sh #!/bin/sh prefix=’/usr/local/nginx’ ./configure –prefix=$prefix –conf-path=$prefix/nginx.conf –sbin-path=$prefix/sbin/nginx –pid-path=$prefix/log/nginx.pid –lock-path=$prefix/log/nginx.lock –error-log-path=$prefix/log/error.log –user=nobody –group=nobody –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_image_filter_module –with-http_geoip_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_degradation_module –with-http_stub_status_module –with-http_perl_module –with-perl=`which perl` –with-google_perftools_module –with-cpp_test_module –with-cpu-opt=pentium4 –http-log-path=$prefix/log/nginx-access.log –http-client-body-temp-path=$prefix/tmp/client –http-proxy-temp-path=$prefix/tmp/proxy –http-fastcgi-temp-path=$prefix/tmp/fastcgi make && make install mkdir -p $prefix/tmp/client && mkdir $prefix/tmp/proxy mkdir $prefix/tmp/fastcgi && chmod -R 777 $prefix/tmp # ./install.sh Configuration summary + using

Nginx Reverse Proxy

Nginx 에서 리버스 프록시를 사용하기 위해서는 3rd party 인 Upstream 모듈이 있어야 합니다. 기본적인 설정은 위키에 더 자세하게 나와 있지만 간단하게 보자면 nginx.conf 파일에 아래 내용을 집어 넣고사용 하시면 됩니다. http { upstream backend  { server backend.example.com:8080 }  server { listen       80; server_name  backend.example.com; location / { proxy_pass  http://backend; } } } 만약 Apache 서버가 포트 8080 으로 사용되고 있다고 치고 Nginx 가 80번 포트를 유지 하면서 리버스 프록시로 Apache 서버로 넘겨 주도록 설정 해줄수 있습니다. 부가 옵션은 여기를 참고 하세요. user  www; pid        log/nginx.pid; error_log  log/error.log;  worker_processes  1; events { worker_connections  1024; use

Nginx userdir setting

userdir은 서버의 사용자 계정을 http://www.yongbok.net/~ruo91 처럼 주 도메인 뒤에 ~ID 형태로 접속 가능하도록 해주며 주로 무료 도메인을 발급 해줄때 유용하게 쓰입니다. 많이 사용하는 아파치에서는 userdir 모듈이 있어야 동작이 가능하지만 Nginx 에서는 리다이렉트로 쉽게 구현이 가능 합니다. # nano /usr/local/etc/nginx/nginx.conf  # Main ( yongbok.net ) server { listen    80; server_name  www.yongbok.net yongbok.net www.yongbok.com yongbok.com www.yongbok.pe.kr yongbok.pe.kr; log_format gzip ‘$remote_addr – $remote_user   ‘ ‘”$request” $status $bytes_sent ‘ ‘”$http_referer” “$http_user_agent” “$gzip_ratio”‘; #access_log  log/www/www-access.log; error_log  log/www/www-error.log; root   /home/www; index  index.php index.html index.htm; if ($host ~* ^180.224.219.12$) { rewrite  ^(.*)$  http://www.yongbok.net$1  last; break; } #——————————————————————-# # userdir redirection ( ~ ) #

Nginx Auth Basic Module

auth_basic 모듈을 Nginx 에서도 사용할수 있습니다. 간략 사용법 location  /  { auth_basic            “인증 메세지”; auth_basic_user_file  /path/to/directory/user-password-file; } 아파치에서 사용하는 htpasswd 바이너리 파일을 이용해 사용자와 비밀번호가 담긴 파일을 생성합니다. (-c 옵션은 새로운 파일을 생성한다는 뜻이며 -m 옵션은 비밀번호를 MD5 로 암호화 합니다. ) 예제1 # /usr/local/apache2/bin/htpasswd -cm /home/ruo91/html/auth/user-pass ruo91 New password: Re-type new password: Adding password for user ruo91 # cat /home/ruo91/html/auth/user-pass ruo91:$apr1$TOQWFAC6$jlvLKdTpXRZMNoSerzEzw1 아파치의 htpasswd 가 없을 경우 python으로 생성시켜 줄수도 있습니다. (htpasswd.py) 옵션 및 사용법 -c : 파일생성 -b : 파일이름 # ./htpasswd.py -c -b 예제2 # wget http://mirror.yongbok.net/ruo91/nginx/script/htpasswd.py # chmod +x htpasswd.py # ./htpasswd.py

FreeBSD – Nginx + FastCGI 설치

Nginx 는 러시아에서 두번째로 방문자수가 많은 Rambler.ru 에서 사용하기 위해 Igor Sysoev 가 만들었다고 합니다. 1. PHP5 설치 FastCGI를 사용하기 위해 설치 합니다. 5.2.x 버전에서는 FastCGI 옵션이 별도로 있었는데 5.3.x 부터는 CGI 옵션으로 통합 되었나 봅니다. # cd /usr/ports/lang/php5 ; make install clean php.ini 파일 복사하구요.. # cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini – PHP5 Extensions 설치 (옵션은 필요한 것만.. 선택하시길..) # cd /usr/ports/lang/php5-extensions ; make install clean 2. spawn-fcgi 설치 # cd /usr/ports/www/spawn-fcgi ; make install clean FastCGI 를 실행 해봅니다. # echo ‘spawn_fcgi_enable=”YES”‘ >> /etc/rc.conf # /usr/local/etc/rc.d/spawn-fcgi start Starting spawn_fcgi. spawn-fcgi: child spawned successfully: PID: 4241 소켓 확인도 해보구요.. # sockstat

1 2 3