nginx安裝(1) ttlsa教程系列之nginx
當(dāng)今nginx的勁頭越來(lái)越猛,記得2011年版本才1.0.6,現(xiàn)在已經(jīng)更新到了1.5.1,nginx的更新速度越來(lái)越快。一直想記錄一系列的nginx教程,處于各種原因沒(méi)去做.今年抽出時(shí)間完成平時(shí)工作上用到的nginx.后續(xù)將會(huì)以視頻教程的方式來(lái)做。當(dāng)然,還是文章先出,下一篇文章將會(huì)講nginx虛擬主機(jī)配置。有什么建議,望大家留言。
1、必要軟件準(zhǔn)備
•安裝pcre
為了支持rewrite功能,我們需要安裝pcre
view sourceprint?
# yum install pcre* //如過(guò)你已經(jīng)裝了,請(qǐng)?zhí)^(guò)這一步
•安裝openssl
需要ssl的支持,如果不需要ssl支持,請(qǐng)?zhí)^(guò)這一步
# yum install openssl*
2、安裝nginx
執(zhí)行如下命令:
# ./configure --prefix=/usr/local/nginx-1.5.1 \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre
–with-http_stub_status_module:支持nginx狀態(tài)查詢(xún)
–with-http_ssl_module:支持https
–with-http_spdy_module:支持google的spdy,想了解請(qǐng)百度spdy,這個(gè)必須有ssl的支持
–with-pcre:為了支持rewrite重寫(xiě)功能,必須制定pcre
最后輸出如下內(nèi)容,表示configure OK了。
...
checking for zlib library ... found
creating objs/Makefile
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx-1.5.1"
nginx binary file: "/usr/local/nginx-1.5.1/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx-1.5.1/conf"
nginx configuration file: "/usr/local/nginx-1.5.1/conf/nginx.conf"
nginx pid file: "/usr/local/nginx-1.5.1/logs/nginx.pid"
nginx error log file: "/usr/local/nginx-1.5.1/logs/error.log"
nginx http access log file: "/usr/local/nginx-1.5.1/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"
# make //確定你的服務(wù)器有安裝make,如果沒(méi)有安裝請(qǐng)執(zhí)行yum install make
# make install
3、啟動(dòng)、關(guān)閉、重置nginx
啟動(dòng):直接執(zhí)行以下命令,nginx就啟動(dòng)了,不需要改任何配置文件,nginx配置多域名虛擬主機(jī)請(qǐng)參考后續(xù)文章.
/usr/local/nginx-1.5.1/sbin/nginx
試試訪(fǎng)問(wèn):我這邊不貼圖,直接使用curl命令來(lái)讀取web信息
[root@ns conf]# curl -s http://localhost | grep nginx.com
nginx.com.
關(guān)閉:
/usr/local/nginx-1.5.1/sbin/nginx -s stop
重置:當(dāng)你有修改配置文件的時(shí)候,只需要reload以下即可
/usr/local/nginx-1.5.1/sbin/nginx -s reload
整個(gè)nginx的安裝就到這里結(jié)束了。
相關(guān)文章
nginx+lua單機(jī)上萬(wàn)并發(fā)的實(shí)現(xiàn)
nginx是我們最常用的服務(wù)器,常用于做內(nèi)容分發(fā)和反向代理,本文主要介紹了nginx+lua單機(jī)上萬(wàn)并發(fā)的實(shí)現(xiàn),有興趣的可以了解下2021-05-05nginx負(fù)載均衡配置,宕機(jī)自動(dòng)切換方式
這篇文章主要介紹了nginx負(fù)載均衡配置,宕機(jī)自動(dòng)切換方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-05-05LNMPA遇到504 Gateway time-out錯(cuò)誤的解決方法
這篇文章主要介紹了LNMPA遇到504 Gateway time-out錯(cuò)誤的解決方法,需要的朋友可以參考下2017-07-07nginx實(shí)現(xiàn)tomcat動(dòng)靜分離詳解
本篇文章主要介紹了nginx實(shí)現(xiàn)tomcat動(dòng)靜分離詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06Nginx配置ssl證書(shū)(https)的全過(guò)程
這篇文章主要介紹了Nginx配置ssl證書(shū)(https)的過(guò)程,在文中大家需要特別注意,如果有防火墻的話(huà),記得開(kāi)通443端口,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2022-10-10