linux安裝nginx
來自: http://my.oschina.net/u/2246410/blog/617586
linux安裝nginx
1、介紹
nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx served or proxied 24.33% busiest sites in January 2016. Here are some of the success stories: Netflix, Wordpress.com, FastMail.FM.
NGINX(engine x)是一個http和反向代理服務器,也是一個郵件代理服務器和一個TCP代理服務器。他是由Igor Sysoev原創并開源。誕生以來,已經在一個俄羅斯的很多高訪問量網站使用,例如:Yandex,Mail.rU,VK和Rambler。2016年一月統計顯示,在廣播領域,NGINX已經有24.33%的占有率,包括很多成功的音樂商店:Netflix,Wordpress.com,FastMail.FM.
2、安裝
a)安裝依賴
#有些系統自帶了pcre,openssl,zlib 1.檢測 pcre (用于nginx的核心和重寫模塊,而且支持正則表達式) :rpm -ql pcre ( 如果沒有就下載安裝: : wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz $ tar -zxf pcre-8.37.tar.gz $ cd pcre-8.37$ $./configure $ make $ sudo make install ) 2.檢測 zlib (nginx的 GZIP模塊,也就是頁面壓縮模塊需要) # rpm -ql zlib ( 如果沒有: $ wget http://zlib.net/zlib-1.2.8.tar.gz $ tar -zxf zlib-1.2.8.tar.gz $ cd zlib-1.2.8 $ ./configure $ make$ sudo make install ) 3. 檢測 openssl (ssl模塊,現在都追求全網ssl) #:rpm -ql openssl ( 安裝: $ wget http://www.openssl.org/source/openssl-1.0.2d.tar.gz $ tar -zxf openssl-1.0.2d.tar.gz $ cd openssl-1.0.2d $ ./Configure darwin64-x86_64-cc --prefix=/usr $ make$ sudo make install )
b)配置安裝環境(二進制安裝)
: wget http://nginx.org/download/nginx-1.8.1.tar.gz :tar -zxvf nginx-1.8.1.tar.gz :cd nginx-1.8.1/ :配置: $:./configure --with-openssl=/usr/bin/openssl
nginx path prefix: "/usr/local/nginx" <nginx的安裝目錄> nginx binary file: "/usr/local/nginx/sbin/nginx" <nginx的啟動文件> nginx configuration prefix: "/usr/local/nginx/conf" <nginx的配置文件存放文件夾> nginx configuration file: "/usr/local/nginx/conf/nginx.conf" <nginx的配置文件> nginx pid file: "/usr/local/nginx/logs/nginx.pid" <nginx的運行時的Pid文件> nginx error log file: "/usr/local/nginx/logs/error.log" <nginx的錯誤日志文件> nginx http access log file: "/usr/local/nginx/logs/access.log" <nginx的訪問日志文件> nginx http client request body temporary files: "client_body_temp" <訪問的request體臨時文件> nginx dso module path: "/usr/local/nginx/modules/" <nginx的模塊文件目錄> nginx http proxy temporary files: "proxy_temp" <nginx的啟動代理模塊文件> nginx http fastcgi temporary files: "fastcgi_temp" <nginx的fastcgi模塊文件> nginx http uwsgi temporary files: "uwsgi_temp" <nginx的uwsig模塊臨時文件> nginx http scgi temporary files: "scgi_temp" <nginx的scgi模塊臨時文件> 安裝 $ make $ make install 開啟 $ cd nginx $ sbin/nginx ######## 操作命令 ################# $ nginx -s stop --快速關閉 $ nginx -s quit --安全關閉 $ nginx -s reload --重新加載,包括配置文件 $ nginx -s reopen --重啟日志文件 $ kill -s QUIT nginx.pid
3、測試
打開瀏覽器:輸入localshot:80
4、configure的配置
--prefix=path defines a directory that will keep NGINX files. The directory will be also used for all relative paths set by the ./configure script (excluding paths to libraries) and for the path to the nginx.conf configuration file. By default the path is set to /usr/local/nginx. 定義保存NGINX的文件夾。這個文件夾將用來在./configure腳本和nginx.cnf中使用。 默認的是 /usr/local/nginx --sbin-path=path sets the name of NGINX executable file. This name is used only during installation. By default the file is named to prefix/sbin/nginx. NGINX的啟動文件存放位置,只有在Make install時使用。 默認:prefix/sbin/nginx --conf-path=path sets the name of the NGINX configuration file. By default the file is named prefix/conf/nginx.conf. Note that regardless of this option you can always start NGINX with a different configuration file by specifying it with the -c option in command-line. 設置NGINX的配置文件存放位置。 默認是 prefix/conf/nginx.conf 注意也可以不用關系這個值,因為NGINX可以使用不同的配置來啟動:nginx -c xxx/nginx.conf --pid-path=path sets the name of the nginx.pid file that stores the process ID of the main process. After installation, the path to the file name can always be changed in the nginx.conf configuration file using the pid directive. By default the file is named prefix/logs/nginx.pid . 設置 nginx.pid 的文件夾,nginx.pid用來存放 主程序的PID。 安裝后,也可以通過 nginx.conf 來配置新的文件存放地址。 默認:prefix/logs/nginx.pid --error-log-path=path sets the name of the primary error, warnings, and diagnostic file. After installation, the file name can always be changed in the nginx.conf configuration file using the error_log directive. By default the file is named prefix/logs/error.log. 主要錯誤日志文件夾。可以通過nginx.conf的 error_log 來修改。 默認:prefix/logs/error.log --http-log-path=path sets the name of the primary request log file of the HTTP server. After installation, the file name can always be changed in the nginx.conf configuration file using the access_log directive. By default the file is named prefix/logs/access.log. 設置主要的訪問日志,可以通過nginx.conf的 access_log 來修改 默認:prefix/logs/access.log --user=name sets the name of an unprivileged user whose credentials will be used by NGINX worker processes. After installation, the name can be changed in the nginx.conf configuration file using the user directive. The default user name is nobody. 設置 worker 線程的 授權用戶。 可以通過nginx.conf的user來修改。 默認是nobody --group=name sets the name of a group whose credentials will be used by NGINX worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. By default, a group name is set to the name of an unprivileged user. 設置 worker 線程的 授權用戶組。 可以通過nginx.conf的user來修改。 默認是不授權的一組。 --with-pcre=path sets the path to the sources of the PCRE library. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module. 設置pcre庫地址(就是安裝地址),用于ngx_http_rewrite_module模塊、正則表達使用 --with-pcre-jit builds the PCRE library with “just-in-time compilation” support (the pcre_jit directive). 創建PCRE的運行時編譯支持,pcre_jit的文件地址 --with-zlib=path sets the path to the sources of the zlib library. The library is required for the ngx_http_gzip_module module. 設置zlib的庫地址,用戶ngx_http_gzip_module模塊(壓縮模塊)
本文由用戶 Mel6545 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!