安裝 Nginx
1. 下載 & 解壓縮
mkdir -p /home/nginx/src cd /home/nginx/src wget http://nginx.org/download/nginx-1.2.3.tar.gz tar xvf nginx-1.2.3.tar.gz cd nginx-1.2.3.tar.gz
2. 安裝
./configure --prefix=/home/nginx make make install安裝資訊
nginx path prefix: "path=/home/nginx" nginx binary file: "path=/home/nginx/sbin/nginx" nginx configuration prefix: "path=/home/nginx/conf" nginx configuration file: "path=/home/nginx/conf/nginx.conf" nginx pid file: "path=/home/nginx/logs/nginx.pid" nginx error log file: "path=/home/nginx/logs/error.log" nginx http access log file: "path=/home/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
3. 設定檔 : /home/nginx/conf/nginx.conf
vi /home/nginx/conf/nginx.conf
#user nobody; user wwwrun www; worker_processes 1; error_log /home/logs/nginx/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /home/logs/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name vote.dev.xuite.net; root /home/www; charset utf-8; #access_log logs/host.access.log main; #location / { # root html; # index index.html index.htm; #} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~\.php$ { fastcgi_pass unix:///tmp/spawn.sock; fastcgi_buffer_size 32k; fastcgi_buffers 32 32k; include fastcgi.conf; } } }到此, 執行 /home/nginx/sbin/nginx 即可啟動 nginx
4. 設定檔 : /etc/init.d/nginx
vi /etc/init.d/nginx
#! /bin/sh ulimit -n 32768 # Source SuSE config (if still necessary, most info has been moved) test -r /etc/rc.config && . /etc/rc.config # Check for missing binaries (stale symlinks should not happen) NGINX_BIN=/home/nginx/sbin/nginx test -x $NGINX_BIN || exit 5 # Check for existence of needed config file and read it NGINX_CONFIG=/home/nginx/conf/nginx.conf test -r $NGINX_CONFIG || exit 6 #. $NGINX_CONFIG # Shell functions sourced from /etc/rc.status: # rc_check check and set local and overall rc status # rc_status check and set local and overall rc status # rc_status -v ditto but be verbose in local rc status # rc_status -v -r ditto and clear the local rc status # rc_failed set local and overall rc status to failed # rc_failedset local and overall rc status to # rc_reset clear local rc status (overall remains) # rc_exit exit appropriate to overall rc status # rc_active checks whether a service is activated by symlinks . /etc/rc.status # First reset status of this service rc_reset case "$1" in start) echo -n "Starting Nginx" ## Start daemon with startproc(8). If this fails ## the echo return value is set appropriate. # NOTE: startproc returns 0, even if service is # already running to match LSB spec. startproc $NGINX_BIN -c $NGINX_CONFIG #startproc $NGINX_BIN # Remember status and be verbose rc_status -v ;; stop) echo -n "Shutting down Nginx" ## Stop daemon with killproc(8) and if this fails ## set echo the echo return value. killproc -TERM $NGINX_BIN # Remember status and be verbose rc_status -v ;; try-restart) ## Stop the service and if this succeeds (i.e. the ## service was running before), start it again. ## Note: try-restart is not (yet) part of LSB (as of 0.7.5) $0 status >/dev/null && $0 restart # Remember status and be quiet rc_status ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start # Remember status and be quiet rc_status ;; force-reload|reload) ## Like force-reload, but if daemon does not support ## signalling, do nothing (!) # If it supports signalling: echo -n "Reload service Nginx" killproc -INT $NGINX_BIN $0 start touch /var/run/nginx.pid rc_status -v ## Otherwise if it does not support reload: #rc_failed 3 #rc_status -v ;; status) echo -n "Checking for service Nginx: " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. # Return value is slightly different for the status command: # 0 - service running # 1 - service dead, but /var/run/ pid file exists # 2 - service dead, but /var/lock/ lock file exists # 3 - service not running # NOTE: checkproc returns LSB compliant status values. checkproc $NGINX_BIN rc_status -v ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 ;; esac rc_exit
cf :
http://nginx.org/
http://wiki.nginx.org/Main
LINUX - 在 Nginx 上跑 php
沒有留言:
張貼留言