當今nginx的勁頭越來越猛,記得2011年版本才1.0.6,現在已經更新到了1.5.1,nginx的更新速度越來越快。一直想記錄一系列的nginx教程,處于各種原因沒去做.今年抽出時間完成平時工作上用到的nginx.后續將會以視頻教程的方式來做。當然,還是文章先出,下一篇文章將會講nginx虛擬主機配置。有什么建議,望大家留言。
1、必要軟件準備
•安裝pcre
為了支持rewrite功能,我們需要安裝pcre
view sourceprint?
# yum install pcre* //如過你已經裝了,請跳過這一步
•安裝openssl
需要ssl的支持,如果不需要ssl支持,請跳過這一步
代碼如下:
# yum install openssl*
2、安裝nginx
執行如下命令:
代碼如下:
# ./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狀態查詢
–with-http_ssl_module:支持https
–with-http_spdy_module:支持google的spdy,想了解請百度spdy,這個必須有ssl的支持
–with-pcre:為了支持rewrite重寫功能,必須制定pcre
最后輸出如下內容,表示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 //確定你的服務器有安裝make,如果沒有安裝請執行yum install make
# make install
3、啟動、關閉、重置nginx
啟動:直接執行以下命令,nginx就啟動了,不需要改任何配置文件,nginx配置多域名虛擬主機請參考后續文章.
代碼如下:
/usr/local/nginx-1.5.1/sbin/nginx
試試訪問:我這邊不貼圖,直接使用curl命令來讀取web信息
代碼如下:
[root@ns conf]# curl -s http://localhost | grep nginx.com
nginx.com.
關閉:
代碼如下:
/usr/local/nginx-1.5.1/sbin/nginx -s stop
新聞熱點
疑難解答