當前位置:首頁 » 編程軟體 » 編譯nginx

編譯nginx

發布時間: 2022-01-09 04:10:46

編譯Nginx需要指定安裝路徑,怎麼才能使編譯的程序在哪個目錄都能運行呢

  1. 配置環境變數
  2. 希望可以幫助你,請採納,謝謝

㈡ 如何避免編譯nginx

如果不想編譯nginx,可以通過使用yum源的方式進行安裝。
註:需要網路通信正常並且epel源有效,參考命令yum install nginx。

㈢ Nginx編譯後修改路徑問題

error.log在nginx.conf裡面重新指定,就固定設置在/tmp吧,linux基本都有的位置
其它幾個temp要在編譯時指定,如

--http-client-body-temp-path=/tmp/client_body_temp
--http-proxy-temp-path=/tmp/proxy_temp
--http-fastcgi-temp-path=/tmp/fastcgi_temp

㈣ ubuntu怎麼編譯nginx

解壓nginx的tar包,進入解壓後的文件夾里,如果要安裝到其他路徑的話,修改configure文件里的prefix的值然後執行./configure,或者直接使用./configure --prefix=/xx/xx/xxx來指定,安裝路徑然後make -j2,如果你的處理器核多,可以增大數字,再然後就是make & make install了。
要注意的是./configure後面可以跟隨很多參數配置:
比如,需要的話可以加上--config-path=/xx/xx/xxx/nginx.conf指定nginx的伺服器配置文件路徑;
--add-mole增加模塊,比如luz、pagespeed、upstream等等,這些都可以在官網上查到。

㈤ nginx編譯的時候是動態編譯還是靜態的

靜態編譯與動態編譯的區別:
1、動態編譯的可執行文件需要附帶一個的動態鏈接庫,在執行時,需要調用其對應動態鏈接庫中的命令。
所以其優點一方面是縮小了執行文件本身的體積,另一方面是加快了編譯速度,節省了系統資源。
缺點一是哪怕是很簡單的程序,只用到了鏈接庫中的一兩條命令,也需要附帶一個相對龐大的鏈接庫;二是如果其他計算機上沒有安裝對應的運行庫,則用動態編譯的可執行文件就不能運行。
2、靜態編譯就是編譯器在編譯可執行文件的時候,將可執行文件需要調用的對應動態鏈接庫(.so)中的部分提取出來,鏈接到可執行文件中去,使可執行文件在運行的時候不依賴於動態鏈接庫。所以其優缺點與動態編譯的可執行文件正好互補。

㈥ 怎麼用編譯後的nginx

測試的話可以進入命令路徑/絕對路徑啟動,一般建議配置成服務方便控制+設置開機啟動。

㈦ 如何在linux下編譯nginx

安裝nginx

1.下載

2.解壓

復制代碼代碼如下:

tar -zxvf nginx-1.7.0.tar.gz

3.編譯和安裝

執行如下命令:

#cdnginx-1.7.0#./configure--prefix=/usr/local/nginx-1.7.0--with-http_ssl_mole--with-http_spdy_mole--with-http_stub_status_mole--with-pcre
–with-http_stub_status_mole:支持nginx狀態查詢–with-http_ssl_mole:支持https–with-http_spdy_mole:支持google的spdy,想了解請網路spdy,這個必須有ssl的支持–with-pcre:為了支持rewrite重寫功能,必須制定pcre

最後輸出如下內容,表示configure OK了。

㈧ 如何 編譯 ngx

一、必要軟體准備
1.安裝pcre

為了支持rewrite功能,我們需要安裝pcre

復制代碼代碼如下:
# yum install pcre* //如過你已經裝了,請跳過這一步

2.安裝openssl
需要ssl的支持,如果不需要ssl支持,請跳過這一步

復制代碼代碼如下:
# yum install openssl*

3.gzip 類庫安裝

復制代碼代碼如下:
yum install zlib zlib-devel

4.安裝wget
下載nginx使用,如果已經安裝,跳過這一步

復制代碼代碼如下:
# yum install wget

二、安裝nginx

1.下載

復制代碼代碼如下:
wget http://nginx.org/download/nginx-1.7.0.tar.gz

2.解壓

復制代碼代碼如下:

tar -zxvf nginx-1.7.0.tar.gz

3.編譯和安裝
執行如下命令:

復制代碼代碼如下:

# cd nginx-1.7.0
# ./configure --prefix=/usr/local/nginx-1.7.0 \
--with-http_ssl_mole --with-http_spdy_mole \
--with-http_stub_status_mole --with-pcre

–with-http_stub_status_mole:支持nginx狀態查詢
–with-http_ssl_mole:支持https
–with-http_spdy_mole:支持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.7.0"
nginx binary file: "/usr/local/nginx-1.7.0/sbin/nginx"
nginx configuration prefix: "/usr/local/nginx-1.7.0/conf"
nginx configuration file: "/usr/local/nginx-1.7.0/conf/nginx.conf"
nginx pid file: "/usr/local/nginx-1.7.0/logs/nginx.pid"
nginx error log file: "/usr/local/nginx-1.7.0/logs/error.log"
nginx http access log file: "/usr/local/nginx-1.7.0/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

三、啟動、關閉、重置nginx
啟動:直接執行以下命令,nginx就啟動了,不需要改任何配置文件,nginx配置多域名虛擬主機請參考後續文章.

復制代碼代碼如下:
/usr/local/nginx-1.7.0/sbin/nginx

試試訪問:直接使用curl命令來讀取web信息

復制代碼代碼如下:

[root@ns conf]
# curl -s http://localhost | grep nginx.com
nginx.com.

關閉:

復制代碼代碼如下:
/usr/local/nginx-1.7.0/sbin/nginx -s stop

重置:當你有修改配置文件的時候,只需要reload以下即可

復制代碼代碼如下:
/usr/local/nginx-1.7.0/sbin/nginx -s reload

整個nginx的安裝就到這里結束了。

四、nginx編譯參數詳解

復制代碼代碼如下:

–prefix= 指向安裝目錄
–sbin-path 指向(執行)程序文件(nginx)
–conf-path= 指向配置文件(nginx.conf)
–error-log-path= 指向錯誤日誌目錄
–pid-path= 指向pid文件(nginx.pid)
–lock-path= 指向lock文件(nginx.lock)(安裝文件鎖定,防止安裝文件被別人利用,或自己誤操作。)
–user= 指定程序運行時的非特權用戶
–group= 指定程序運行時的非特權用戶組
–builddir= 指向編譯目錄
–with-rtsig_mole 啟用rtsig模塊支持(實時信號)
–with-select_mole 啟用select模塊支持(一種輪詢模式,不推薦在高載環境下使用)禁用:–without-select_mole
–with-poll_mole 啟用poll模塊支持(功能與select相同,與select特性相同,為一種輪詢模式,不推薦在高載環境下使用)
–with-file-aio 啟用file aio支持(一種APL文件傳輸格式)
–with-ipv6 啟用ipv6支持
–with-http_ssl_mole 啟用ngx_http_ssl_mole支持(使支持https請求,需已安裝openssl)
–with-http_realip_mole 啟用ngx_http_realip_mole支持(這個模塊允許從請求標頭更改客戶端的IP地址值,默認為關)
–with-http_addition_mole 啟用ngx_http_addition_mole支持(作為一個輸出過濾器,支持不完全緩沖,分部分響應請求)
–with-http_xslt_mole 啟用ngx_http_xslt_mole支持(過濾轉換XML請求)
–with-http_image_filter_mole 啟用ngx_http_image_filter_mole支持(傳輸JPEG/GIF/PNG 圖片的一個過濾器)(默認為不啟用。gd庫要用到)
–with-http_geoip_mole 啟用ngx_http_geoip_mole支持(該模塊創建基於與MaxMind GeoIP二進制文件相配的客戶端IP地址的ngx_http_geoip_mole變數)
–with-http_sub_mole 啟用ngx_http_sub_mole支持(允許用一些其他文本替換nginx響應中的一些文本)
–with-http_dav_mole 啟用ngx_http_dav_mole支持(增加PUT,DELETE,MKCOL:創建集合,COPY和MOVE方法)默認情況下為關閉,需編譯開啟
–with-http_flv_mole 啟用ngx_http_flv_mole支持(提供尋求內存使用基於時間的偏移量文件)
–with-http_gzip_static_mole 啟用ngx_http_gzip_static_mole支持(在線實時壓縮輸出數據流)
–with-http_random_index_mole 啟用ngx_http_random_index_mole支持(從目錄中隨機挑選一個目錄索引)
–with-http_secure_link_mole 啟用ngx_http_secure_link_mole支持(計算和檢查要求所需的安全鏈接網址)
–with-http_degradation_mole 啟用ngx_http_degradation_mole支持(允許在內存不足的情況下返回204或444碼)
–with-http_stub_status_mole 啟用ngx_http_stub_status_mole支持(獲取nginx自上次啟動以來的工作狀態)
–without-http_charset_mole 禁用ngx_http_charset_mole支持(重新編碼web頁面,但只能是一個方向–伺服器端到客戶端,並且只有一個位元組的編碼可以被重新編碼)
–without-http_gzip_mole 禁用ngx_http_gzip_mole支持(該模塊同-with-http_gzip_static_mole功能一樣)
–without-http_ssi_mole 禁用ngx_http_ssi_mole支持(該模塊提供了一個在輸入端處理處理伺服器包含文件(SSI)的過濾器,目前支持SSI命令的列表是不完整的)
–without-http_userid_mole 禁用ngx_http_userid_mole支持(該模塊用來處理用來確定客戶端後續請求的cookies)
–without-http_access_mole 禁用ngx_http_access_mole支持(該模塊提供了一個簡單的基於主機的訪問控制。允許/拒絕基於ip地址)
–without-http_auth_basic_mole禁用ngx_http_auth_basic_mole(該模塊是可以使用用戶名和密碼基於http基本認證方法來保護你的站點或其部分內容)
–without-http_autoindex_mole 禁用disable ngx_http_autoindex_mole支持(該模塊用於自動生成目錄列表,只在ngx_http_index_mole模塊未找到索引文件時發出請求。)
–without-http_geo_mole 禁用ngx_http_geo_mole支持(創建一些變數,其值依賴於客戶端的IP地址)
–without-http_map_mole 禁用ngx_http_map_mole支持(使用任意的鍵/值對設置配置變數)
–without-http_split_clients_mole 禁用ngx_http_split_clients_mole支持(該模塊用來基於某些條件劃分用戶。條件如:ip地址、報頭、cookies等等)
–without-http_referer_mole 禁用disable ngx_http_referer_mole支持(該模塊用來過濾請求,拒絕報頭中Referer值不正確的請求)
–without-http_rewrite_mole 禁用ngx_http_rewrite_mole支持(該模塊允許使用正則表達式改變URI,並且根據變數來轉向以及選擇配置。如果在server級別設置該選項,那麼他們將在 location之前生效。如果在location還有更進一步的重寫規則,location部分的規則依然會被執行。如果這個URI重寫是因為location部分的規則造成的,那麼 location部分會再次被執行作為新的URI。 這個循環會執行10次,然後Nginx會返回一個500錯誤。)
–without-http_proxy_mole 禁用ngx_http_proxy_mole支持(有關代理伺服器
–without-http_fastcgi_mole 禁用ngx_http_fastcgi_mole支持(該模塊允許Nginx 與FastCGI 進程交互,並通過傳遞參數來控制FastCGI 進程工作。 )FastCGI一個常駐型的公共網關介面。
–without-http_uwsgi_mole 禁用ngx_http_uwsgi_mole支持(該模塊用來醫用uwsgi協議,uWSGI伺服器相關)
–without-http_scgi_mole 禁用ngx_http_scgi_mole支持(該模塊用來啟用SCGI協議支持,SCGI協議是CGI協議的替代。它是一種應用程序與HTTP服務介面標准。它有些像FastCGI但他的設計 更容易實現。)
–without-http_memcached_mole 禁用ngx_http_memcached_mole支持(該模塊用來提供簡單的緩存,以提高系統效率)
-without-http_limit_zone_mole 禁用ngx_http_limit_zone_mole支持(該模塊可以針對條件,進行會話的並發連接數控制)
–without-http_limit_req_mole 禁用ngx_http_limit_req_mole支持(該模塊允許你對於一個地址進行請求數量的限制用一個給定的session或一個特定的事件)
–without-http_empty_gif_mole 禁用ngx_http_empty_gif_mole支持(該模塊在內存中常駐了一個1*1的透明GIF圖像,可以被非常快速的調用)
–without-http_browser_mole 禁用ngx_http_browser_mole支持(該模塊用來創建依賴於請求報頭的值。如果瀏覽器為modern ,則$modern_browser等於modern_browser_value指令分配的值;如 果瀏覽器為old,則$ancient_browser等於 ancient_browser_value指令分配的值;如果瀏覽器為 MSIE中的任意版本,則 $msie等於1)
–without-http_upstream_ip_hash_mole 禁用ngx_http_upstream_ip_hash_mole支持(該模塊用於簡單的負載均衡)
–with-http_perl_mole 啟用ngx_http_perl_mole支持(該模塊使nginx可以直接使用perl或通過ssi調用perl)
–with-perl_moles_path= 設定perl模塊路徑
–with-perl= 設定perl庫文件路徑
–http-log-path= 設定access log路徑
–http-client-body-temp-path= 設定http客戶端請求臨時文件路徑
–http-proxy-temp-path= 設定http代理臨時文件路徑
–http-fastcgi-temp-path= 設定http fastcgi臨時文件路徑
–http-uwsgi-temp-path= 設定http uwsgi臨時文件路徑
–http-scgi-temp-path= 設定http scgi臨時文件路徑
-without-http 禁用http server功能
–without-http-cache 禁用http cache功能
–with-mail 啟用POP3/IMAP4/SMTP代理模塊支持
–with-mail_ssl_mole 啟用ngx_mail_ssl_mole支持
–without-mail_pop3_mole 禁用pop3協議(POP3即郵局協議的第3個版本,它是規定個人計算機如何連接到互聯網上的郵件伺服器進行收發郵件的協議。是網際網路電子郵件的第一個離線協議標 准,POP3協議允許用戶從伺服器上把郵件存儲到本地主機上,同時根據客戶端的操作刪除或保存在郵件伺服器上的郵件。POP3協議是TCP/IP協議族中的一員,主要用於 支持使用客戶端遠程管理在伺服器上的電子郵件)
–without-mail_imap_mole 禁用imap協議(一種郵件獲取協議。它的主要作用是郵件客戶端可以通過這種協議從郵件伺服器上獲取郵件的信息,下載郵件等。IMAP協議運行在TCP/IP協議之上, 使用的埠是143。它與POP3協議的主要區別是用戶可以不用把所有的郵件全部下載,可以通過客戶端直接對伺服器上的郵件進行操作。)
–without-mail_smtp_mole 禁用smtp協議(SMTP即簡單郵件傳輸協議,它是一組用於由源地址到目的地址傳送郵件的規則,由它來控制信件的中轉方式。SMTP協議屬於TCP/IP協議族,它幫助每台計算機在發送或中轉信件時找到下一個目的地。)
–with-google_perftools_mole 啟用ngx_google_perftools_mole支持(調試用,剖析程序性能瓶頸)
–with-cpp_test_mole 啟用ngx_cpp_test_mole支持
–add-mole= 啟用外部模塊支持
–with-cc= 指向C編譯器路徑
–with-cpp= 指向C預處理路徑
–with-cc-opt= 設置C編譯器參數(PCRE庫,需要指定–with-cc-opt=」-I /usr/local/include」,如果使用select()函數則需要同時增加文件描述符數量,可以通過–with-cc- opt=」-D FD_SETSIZE=2048」指定。)
–with-ld-opt= 設置連接文件參數。(PCRE庫,需要指定–with-ld-opt=」-L /usr/local/lib」。)
–with-cpu-opt= 指定編譯的CPU,可用的值為: pentium, pentiumpro, pentium3, pentium4, athlon, opteron, amd64, sparc32, sparc64, ppc64
–without-pcre 禁用pcre庫
–with-pcre 啟用pcre庫
–with-pcre= 指向pcre庫文件目錄
–with-pcre-opt= 在編譯時為pcre庫設置附加參數
–with-md5= 指向md5庫文件目錄(消息摘要演算法第五版,用以提供消息的完整性保護)
–with-md5-opt= 在編譯時為md5庫設置附加參數
–with-md5-asm 使用md5匯編源
–with-sha1= 指向sha1庫目錄(數字簽名演算法,主要用於數字簽名)
–with-sha1-opt= 在編譯時為sha1庫設置附加參數
–with-sha1-asm 使用sha1匯編源
–with-zlib= 指向zlib庫目錄
–with-zlib-opt= 在編譯時為zlib設置附加參數
–with-zlib-asm= 為指定的CPU使用zlib匯編源進行優化,CPU類型為pentium, pentiumpro
–with-libatomic 為原子內存的更新操作的實現提供一個架構
–with-libatomic= 指向libatomic_ops安裝目錄
–with-openssl= 指向openssl安裝目錄
–with-openssl-opt 在編譯時為openssl設置附加參數
–with-debug 啟用debug日誌

㈨ window版本的nginx能重新編譯嗎如何添加新的模塊呢

找到安裝nginx的源碼根目錄,如果沒有的話下載新的源碼
http://nginx.org
tar xvzf nginx-1.3.2.tar.gz
查看ngixn版本極其編譯參數
/usr/local/nginx/sbin/nginx -V
進入nginx源碼目錄
cd nginx-1.3.2
以下是重新編譯的代碼和模塊
./configure --prefix=/usr/local/nginx--with-http_stub_status_mole
--with-http_ssl_mole --with-file-aio --with-http_realip_mole
make 千萬別make install,否則就覆蓋安裝了
make完之後在objs目錄下就多了個nginx,這個就是新版本的程序了
備份舊的nginx程序
cp /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak
把新的nginx程序覆蓋舊的
cp objs/nginx /usr/local/nginx/sbin/nginx
測試新的nginx程序是否正確
/usr/local/nginx/sbin/nginx -t
nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx:configuration file /usr/local/nginx/conf/nginx.conf test issuccessful
平滑重啟nginx
/usr/local/nginx/sbin/nginx -s reload
查看ngixn版本極其編譯參數
/usr/local/nginx/sbin/nginx -V
這是我重新編譯的代碼:
./configure --prefix=/usr/local/nginx --with-google_perftools_mole
--user=www --group=www --with-http_stub_status_mole
--with-http_gzip_static_mole --with-openssl=/usr/
--with-pcre=/mydata/soft/pcre-8.31

熱點內容
c語言宏定義字元串 發布:2024-04-20 18:22:45 瀏覽:471
現在玩游戲的電腦需要什麼配置 發布:2024-04-20 17:09:57 瀏覽:195
游樂園的密碼一般為多少 發布:2024-04-20 17:09:51 瀏覽:41
興元安卓機怎麼進系統 發布:2024-04-20 17:07:16 瀏覽:806
我的世界伺服器如何放村民 發布:2024-04-20 17:05:35 瀏覽:359
手機反編譯dex 發布:2024-04-20 17:01:01 瀏覽:704
安卓怎麼設置微信拍一拍 發布:2024-04-20 16:44:48 瀏覽:569
三星3熱點密碼怎麼設置 發布:2024-04-20 16:30:52 瀏覽:579
用keil編譯顯示警告warn 發布:2024-04-20 16:27:09 瀏覽:894
訪問在哪兒 發布:2024-04-20 16:20:42 瀏覽:201