nginx學習----1

來源:互聯網
上載者:User

標籤:http   io   使用   ar   檔案   sp   on   問題   log   

本節主要:

  1.在linux下Nginx的安裝,啟動,重啟,停止

  2.設定檔的詳解

 

一,在linux下Nginx的安裝

  在做j2ee開發時候,一直以來,都使用nginx做負載平衡,可從來自己沒有去從無到有去建設,最近開發新的平台,想在自己測試機子上使用nginx,於是自己親手搭建,發現很多問題,也花了很多時間才搭建完成,現在將過程記錄下來。在開始我從網上下載nginx-1.4.7.tar.gz,放在/usr/local/nginx下,解壓後,得到nginx-1.4.7檔案夾,由於平時在window下,養成了喜歡使用檔案夾的名稱比較好看,於是將該檔案夾的名稱修改nginx,然後在命令列一次執行:./configure    make    make install。先是報缺失包的錯誤,才知道,要安裝nginx,需要外部包,gcc  pcre pcre-deve  ssl,還好我的測試機子上有yum,就用yum命令安裝了這些包,接著就報"/usr/local/nginx"檔案夾的問題。當時就想不明白怎麼回事,就將報的錯誤複製到瀏覽器上百度一把,得到很多都是要執行 ./configure --prefix=/usr/local/nginx ,反正在./configure後面帶很多參數,試了幾個發現不行,就到網上搜一下,很多說要指向pcre  ssl等源碼路徑,我都是yum安裝的,我去哪裡搞源碼路徑。當時想過把pcre ssl等下載了,用源碼安裝,但是太懶了,覺得會很麻煩,又在網上找了很久,實在沒有辦法。我就想不可能安裝一個nginx這麼麻煩,一定是我的問題,我就將解壓後的檔案刪除了,重新解壓,然後直接執行./configure    make    make install,來一個window下的傻瓜式安裝,結果就ok了。我當時就明白了,nginx預設安裝路徑是/usr/local/nginx,自己剛才把這個路徑給佔了,又沒有重新指定,真笨啊,得好好學習一下linux,太耗時了,笨的可怕。下面貼出一些在過程中使用的命令:

a.檢查是否安裝了yum
直接在命令列,輸入yum,如果安裝了,就會顯示yum命令的可選項

b.檢查是否安裝了pcre

直接在命令列,輸入rpm -qa | grep pcre

c.檢查是否安裝了gcc
直接在命令列,輸入gcc -v

 

  執行./configure成功後列印的資訊:

  

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ md5: using system crypto library
+ sha1: using system crypto library
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/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"

 

 

 安裝完如何檢查是否安裝成功呢?

  在nginx的安裝目錄有sbin/nginx可執行檔,使用/usr/local/nginx/sbin/nginx啟動。在瀏覽器中輸入ip地址,斷行符號,如果返回一個nginx歡迎頁面就是成功了

停止命令:kill -QUIT  主進程號

nginx學習----1

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.