nginx wiki 中文站:http://wiki.nginx.org/Chs
添加使用者和組
groupadd www useradd -g www -M www
1.安裝nginx所需的pcre庫
tar zxvf pcre-7.8.tar.gz cd pcre-7.8/ ./configure make && make install cd ../
2、安裝Nginx
tar zxvf nginx-1.0.4.tar.gz cd nginx-1.0.4/ ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module make && make install cd ../
vim /etc/init.d/nginx 將下面的代碼複製進去儲存。
小插曲VI 小技巧
vi一般用法
一般模式 編輯模式 指令模式
h 左 a,i,r,o,A,I,R,O :w 儲存
j 下 進入編輯模式 :w! 強制儲存
k 上 dd 刪除游標當前行 :q! 不儲存離開
l 右 ndd 刪除n行 :wq! 儲存後離開
0 移動到行首 yy 複製當前行 :e! 還原原始檔
$ 移動到行尾 nyy 複製n行 :w filename 另存新檔
H 螢幕最上 p,P 粘貼 :set nu 設定行號
M 螢幕中央 u 撤消 :set nonu 取消行號
L 螢幕最下 [Ctrl]+r 重做上一個動作 ZZ 儲存離開
G 檔案最後一行 [ctrl]+z 暫停退出 :set nohlsearch 永久地關閉高亮顯示
/work 向下搜尋 :sp 同時開啟兩個文檔
?work 向上搜尋 [Ctrl]+w 兩個文檔設換
gg 移動到檔案第一行 :nohlsearch 暫時關閉高亮顯示
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/usr/local/nginx/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/su