Linux 添加Nginx 到 service 啟動 (完整篇)__Linux

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.