亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 網站 > Nginx > 正文

CentOS 7.2安裝Nginx 1.10.2的詳細教程

2024-08-30 12:28:22
字體:
來源:轉載
供稿:網友

一、使用Yum安裝(推薦)

使用Yum安裝是推薦的方式,整體的流程非常的簡單,也不容易出錯,如果不需要什么特殊配置,建議使用Yum盡進行安裝。

1、安裝epel-release源并進行安裝

yum install epel-releaseyum updateyum install nginx

2、執行相關的應用操作

systemctl start nginx #啟動systemctl stop nginx #停止systemctl restart nginx #重啟systemctl status nginx #查看運行狀態systemctl enable nginx #開機啟動

3、設置防火墻

在啟動完以后可能無法通過IP訪問,需要進一步設置防火墻

firewall-cmd --permanent --zone=public --add-service=http firewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload

至此,安裝完畢。

參考文章:https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7

二、通過源碼編譯安裝

1、安裝編譯所需工具

yum groupinstall "Development Tools"yum install wget

2、到官網下載最新的源代碼(https://nginx.org/en/)

cd /usr/local/srcwget http://nginx.org/download/nginx-1.10.2.tar.gztar zxvf nginx-1.10.2.tar.gz

3、安裝依賴包

yum install zlib zlib-devel openssl openssl-devel pcre pcre-devel

      zlib: 為nginx提供gzip模塊,需要zlib庫支持,傳輸數據打包,省流量(但消耗資源)

      openssl: 為nginx提供ssl功能

      pcre: 為支持地址重寫rewrite功能

4、創建用來運行nginx的用戶及組

groupadd nginxuseradd -g nginx -M nginx –s /sbin/nologin

-g參數為nginx用戶指定了一個組。-M參數保證其不自動生成home目錄。

5、編譯源代碼

先使用./configure –help 查看編譯幫助:

[root@localhost nginx-1.10.2]# ./configure --help  --help        print this message  --prefix=PATH      set installation prefix #Nginx安裝的根路徑,默認為 /usr/local/nginx。 --sbin-path=PATH     set nginx binary pathname #指定nginx二進制文件的路徑,默認為PATH/sbin/nginx。 --modules-path=PATH    set modules path #Perl模塊位置 --conf-path=PATH     set nginx.conf pathname #設定nginx配置文件地址,默認為PATH/conf/nginx.conf。 --error-log-path=PATH    set error log pathname #錯誤文件路徑,默認為 PATH/logs/error.log。 --pid-path=PATH     set nginx.pid pathname # master進程pid寫入的文件位置,通常在var/run下,默認為 PATH/logs/nginx.pid。 --lock-path=PATH     set nginx.lock pathname #共享存儲器互斥鎖文件路徑  --user=USER      set non-privileged user for worker processes #指定程序運行時的非特權用戶 --group=GROUP      set non-privileged group for worker processes #指定程序運行時的非特權用戶組  --build=NAME      set build name #編譯名稱 --builddir=DIR      set build directory #指向編譯目錄  --with-select_module    enable select module 允許或不允許開啟SELECT模式,如果configure沒有找到合適的模式,比如,kqueue(sun os)、epoll(linux kenel 2.6+)、rtsig(實時信號) --without-select_module   disable select module 禁用select模塊支持 --with-poll_module     enable poll module 啟用poll模塊支持(功能與select相同,與select特性相同,為一種輪詢模式,不推薦在高載環境下使用) --without-poll_module    disable poll module 禁用poll模塊支持  --with-threads      enable thread pool support  --with-file-aio     enable file AIO support #為freeBSD4.3+和linux2.6.22+系統啟用異步io  --with-ipv6      enable IPv6 support #啟用ipv6支持 #默認禁用的模塊 --with-http_ssl_module    enable ngx_http_ssl_module #使支持https請求,需已安裝openssl --with-http_v2_module    enable ngx_http_v2_module #啟用HTTP V2 --with-http_realip_module   enable ngx_http_realip_module #此模塊支持顯示真實來源IP地址,主要用于NGINX做前端負載均衡服務器使用 --with-http_addition_module  enable ngx_http_addition_module #輸出過濾器,使你能夠在請求經過一個location前或后時在該location本身添加內容 --with-http_xslt_module   enable ngx_http_xslt_module #這個模塊是一個過濾器,它可以通過XSLT模板轉換XML應答 --with-http_xslt_module=dynamic enable dynamic ngx_http_xslt_module  --with-http_image_filter_module enable ngx_http_image_filter_module #圖像過濾器,在將圖像投遞到客戶之前進行處理(需要libgd庫) --with-http_image_filter_module=dynamic          enable dynamic ngx_http_image_filter_module  --with-http_geoip_module   enable ngx_http_geoip_module #創建基于與MaxMind GeoIP相配的客戶端地址 --with-http_geoip_module=dynamic enable dynamic ngx_http_geoip_module --with-http_sub_module    enable ngx_http_sub_module #這個模塊可以能夠在nginx的應答中搜索并替換文本 --with-http_dav_module    enable ngx_http_dav_module #為文件和目錄指定權限,限制不同類型的用戶對于頁面有不同的操作權限 --with-http_flv_module    enable ngx_http_flv_module #這個模塊支持對FLV(flash)文件的拖動播放 --with-http_mp4_module    enable ngx_http_mp4_module #支持H.264/AAC文件為偽流媒體 --with-http_gunzip_module   enable ngx_http_gunzip_module #對于不支持gzip編碼的客戶,該模塊用于為客戶解壓縮預壓縮內容 --with-http_gzip_static_module  enable ngx_http_gzip_static_module #這個模塊在一個預壓縮文件傳送到開啟Gzip壓縮的客戶端之前檢查是否已經存在以“.gz”結尾的壓縮文件,這樣可以防止文件被重復壓縮 --with-http_auth_request_module enable ngx_http_auth_request_module  --with-http_random_index_module enable ngx_http_random_index_module #從目錄中選擇一個隨機主頁 --with-http_secure_link_module  enable ngx_http_secure_link_module #該模塊提供一種機制,它會將一個哈希值鏈接到一個url中,因此,只有那些使用正確的密碼能夠計算鏈接 --with-http_degradation_module  enable ngx_http_degradation_module #允許在內存不足的情況下返回204或444碼 --with-http_slice_module   enable ngx_http_slice_module  --with-http_stub_status_module  enable ngx_http_stub_status_module #取得一些nginx的運行狀態,輸出的狀態信息可使用RRDtool或類似的工具繪制成圖#默認啟用的模塊 --without-http_charset_module  disable ngx_http_charset_module #重新編碼web頁面 --without-http_gzip_module   disable ngx_http_gzip_module #同-with-http_gzip_static_module功能一樣 --without-http_ssi_module   disable ngx_http_ssi_module #提供在輸入端處理處理服務器包含文件(SSI)的過濾器,目前支持SSI命令的列表是不完整的 --without-http_userid_module  disable ngx_http_userid_module #用來處理用來確定客戶端后續請求的cookies --without-http_access_module  disable ngx_http_access_module #供了一個簡單的基于主機的訪問控制。允許/拒絕基于ip地址 --without-http_auth_basic_module disable ngx_http_auth_basic_module #可以使用用戶名和密碼基于http基本認證方法來保護你的站點或其部分內容 --without-http_autoindex_module disable ngx_http_autoindex_module #自動生成目錄列表,只在ngx_http_index_module模塊未找到索引文件時發出請求。 --without-http_geo_module   disable ngx_http_geo_module #創建一些變量,其值依賴于客戶端的IP地址 --without-http_map_module   disable ngx_http_map_module #使用任意的鍵/值對設置配置變量 --without-http_split_clients_module disable ngx_http_split_clients_module #用來基于某些條件劃分用戶。條件如:ip地址、報頭、cookies等等 --without-http_referer_module  disable ngx_http_referer_module #用來過濾請求,拒絕報頭中Referer值不正確的請求 --without-http_rewrite_module  disable ngx_http_rewrite_module #允許使用正則表達式改變URI,并且根據變量來轉向以及選擇配置 --without-http_proxy_module  disable ngx_http_proxy_module #有關代理服務器 --without-http_fastcgi_module  disable ngx_http_fastcgi_module #允許Nginx 與FastCGI 進程交互,并通過傳遞參數來控制FastCGI 進程工作。 --without-http_uwsgi_module  disable ngx_http_uwsgi_module #用來使用uwsgi協議,uWSGI服務器相關 --without-http_scgi_module   disable ngx_http_scgi_module #用來啟用SCGI協議支持,SCGI協議是CGI協議的替代。 --without-http_memcached_module disable ngx_http_memcached_module #用來提供簡單的緩存,以提高系統效率 --without-http_limit_conn_module disable ngx_http_limit_conn_module #允許你對于一個地址進行連接數的限制用一個給定的session或一個特定的事件 --without-http_limit_req_module disable ngx_http_limit_req_module #允許你對于一個地址進行請求數量的限制用一個給定的session或一個特定的事件 --without-http_empty_gif_module disable ngx_http_empty_gif_module #在內存中常駐了一個1*1的透明GIF圖像,可以被非常快速的調用 --without-http_browser_module  disable ngx_http_browser_module #用來創建依賴于請求報頭的值 --without-http_upstream_hash_module          disable ngx_http_upstream_hash_module #用于簡單的負載均衡 --without-http_upstream_ip_hash_module          disable ngx_http_upstream_ip_hash_module  --without-http_upstream_least_conn_module          disable ngx_http_upstream_least_conn_module  --without-http_upstream_keepalive_module          disable ngx_http_upstream_keepalive_module --without-http_upstream_zone_module          disable ngx_http_upstream_zone_module  --with-http_perl_module   enable ngx_http_perl_module #這個模塊允許nginx使用SSI調用perl或直接執行perl(使用會降低性能) --with-http_perl_module=dynamic enable dynamic ngx_http_perl_module --with-perl_modules_path=PATH  set Perl modules path #設定perl模塊路徑 --with-perl=PATH     set perl binary pathname #設定perl庫文件路徑  --http-log-path=PATH    set http access log pathname #設定access log路徑 --http-client-body-temp-path=PATH set path to store http client request body temporary files #設定http客戶端請求臨時文件路徑 --http-proxy-temp-path=PATH  set path to store http proxy temporary files #設定http代理臨時文件路徑 --http-fastcgi-temp-path=PATH  set path to store http fastcgi temporary files #設定http fastcgi臨時文件路徑 --http-uwsgi-temp-path=PATH  set path to store http uwsgi temporary files #設定http uwsgi臨時文件路徑 --http-scgi-temp-path=PATH   set path to store http scgi temporary files #設定http scgi臨時文件路徑  --without-http      disable HTTP server #完全禁用http模塊,如果只想支持mall,可以使用此項設置 --without-http-cache    disable HTTP cache #在使用upstream模塊時,nginx能夠配置本地緩存內容,此選項可禁用緩存  --with-mail      enable POP3/IMAP4/SMTP proxy module #激活POP3/IMAP4/SMTP代理模塊,默認未激活 --with-mail=dynamic    enable dynamic POP3/IMAP4/SMTP proxy module --with-mail_ssl_module    enable ngx_mail_ssl_module #SMTP可以使用SSL/TLS.配置已經定義了HTTP SSL模塊,但是不支持客戶端證書檢測 --without-mail_pop3_module   disable ngx_mail_pop3_module #啟用mail模塊后,單獨禁用pop3模塊 --without-mail_imap_module   disable ngx_mail_imap_module #啟用mail模塊后,單獨禁用imap模塊 --without-mail_smtp_module   disable ngx_mail_smtp_module #啟用mail模塊后,單獨禁用smtp模塊  --with-stream      enable TCP/UDP proxy module --with-stream=dynamic    enable dynamic TCP/UDP proxy module --with-stream_ssl_module   enable ngx_stream_ssl_module --without-stream_limit_conn_module disable ngx_stream_limit_conn_module --without-stream_access_module  disable ngx_stream_access_module --without-stream_upstream_hash_module          disable ngx_stream_upstream_hash_module --without-stream_upstream_least_conn_module          disable ngx_stream_upstream_least_conn_module --without-stream_upstream_zone_module          disable ngx_stream_upstream_zone_module  --with-google_perftools_module  enable ngx_google_perftools_module #調試用,剖析程序性能瓶頸 --with-cpp_test_module    enable ngx_cpp_test_module  --add-module=PATH     enable external module #啟用外部模塊支持 --add-dynamic-module=PATH   enable dynamic external module#編譯相關的參數 --with-cc=PATH      set C compiler pathname #如果想設置一個不在默認path下的c編譯器 --with-cpp=PATH     set C preprocessor pathname #設置c預處理器的相對路徑 --with-cc-opt=OPTIONS    set additional C compiler options #設置C編譯器參數 --with-ld-opt=OPTIONS    set additional linker options #包含連接庫的路徑和運行路徑 --with-cpu-opt=CPU     build for the specified CPU, valid values:pentium, pentiumpro, pentium3, pentium4,athlon, opteron, sparc32, sparc64, ppc64 #指定編譯的CPU  --without-pcre      disable PCRE library usage #禁用pcre庫 --with-pcre      force PCRE library usage #啟用pcre庫 --with-pcre=DIR     set path to PCRE library sources #指向pcre庫文件目錄 --with-pcre-opt=OPTIONS   set additional build options for PCRE #在編譯時為pcre庫設置附加參數 --with-pcre-jit     build PCRE with JIT compilation support  --with-md5=DIR      set path to md5 library sources #指向md5庫文件目錄 --with-md5-opt=OPTIONS    set additional build options for md5 #在編譯時為md5庫設置附加參數 --with-md5-asm      use md5 assembler sources #使用md5匯編源  --with-sha1=DIR     set path to sha1 library sources #指向sha1庫目錄 --with-sha1-opt=OPTIONS   set additional build options for sha1 #在編譯時為sha1庫設置附加參數 --with-sha1-asm     use sha1 assembler sources #使用sha1匯編源  --with-zlib=DIR     set path to zlib library sources #指向zlib庫目錄 --with-zlib-opt=OPTIONS   set additional build options for zlib #在編譯時為zlib設置附加參數 --with-zlib-asm=CPU    use zlib assembler sources optimized for the specified CPU, valid values: pentium, pentiumpro #為指定的CPU使用zlib匯編源進行優化  --with-libatomic     force libatomic_ops library usage # 為原子內存的更新操作的實現提供一個架構 --with-libatomic=DIR    set path to libatomic_ops library sources #指向libatomic_ops安裝目錄  --with-openssl=DIR     set path to OpenSSL library sources #指向openssl安裝目錄 --with-openssl-opt=OPTIONS   set additional build options for OpenSSL #在編譯時為openssl設置附加參數  --with-debug      enable debug logging #啟用debug日志

設置編譯參數:

./configure /--prefix=/usr/local/nginx /--sbin-path=/usr/sbin/nginx /--conf-path=/etc/nginx/nginx.conf /--error-log-path=/var/log/nginx/error.log /--http-log-path=/var/log/nginx/access.log /--pid-path=/var/run/nginx.pid /--lock-path=/var/run/nginx.lock /--user=nginx /--group=nginx /--with-http_ssl_module /--with-pcre /--with-http_v2_module /--with-http_realip_module /--with-http_addition_module /--with-http_sub_module /--with-http_dav_module /--with-http_gunzip_module /--with-http_gzip_static_module /--with-http_random_index_module /--with-http_secure_link_module /--with-http_stub_status_module /--with-http_auth_request_module

然后執行 make && make install  完成安裝后在 centos7 中為nginx的啟動、重啟、重載配置添加腳本

vi /usr/lib/systemd/system/nginx

添加內容:

[Unit]Description=nginx - high performance web serverDocumentation=http://nginx.org/en/docs/After=network.target remote-fs.target nss-lookup.target [Service]Type=forkingPIDFile=/var/run/nginx.pidExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true [Install]WantedBy=multi-user.target

相關操作:

systemctl is-enabled nginx.service #查詢nginx是否開機啟動systemctl enable nginx.service #開機運行nginxsystemctl disable nginx.service #取消開機運行nginxsystemctl start nginx.service #啟動nginxsystemctl stop nginx.service #停止nginxsystemctl restart nginx.service #重啟nginxsystemctl reload nginx.service #重新加載nginx配置文件systemctl status nginx.service #查詢nginx運行狀態systemctl --failed #顯示啟動失敗的服務

總結

以上就是CentOS 7.2安裝Nginx 1.10.2的詳細教程,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久久久久久久久久av| 欧美日韩视频在线| 国产视频在线观看一区二区| 欧美精品在线视频观看| 97精品国产91久久久久久| 欧美成人精品影院| 成人乱人伦精品视频在线观看| 92看片淫黄大片欧美看国产片| 伊人久久男人天堂| 久久久久久久激情视频| 国产精品狼人色视频一区| 欧美二区在线播放| 国产欧美久久一区二区| 国产精品久久久久久久久久东京| 亚洲国产精彩中文乱码av在线播放| 亚洲一区国产精品| 精品亚洲男同gayvideo网站| 欧美丝袜一区二区| 久久亚洲精品一区二区| 亚洲国产欧美一区二区丝袜黑人| 性欧美视频videos6一9| 国产成人福利视频| 深夜成人在线观看| 综合久久五月天| 国产精品福利网站| 欧美丰满老妇厨房牲生活| 久热精品视频在线免费观看| 国产欧美精品一区二区三区-老狼| 欧美一级视频免费在线观看| 欧美激情亚洲激情| 色偷偷91综合久久噜噜| 日韩亚洲精品电影| 热re99久久精品国产66热| 亚洲视频在线视频| 国内精品小视频| 狠狠综合久久av一区二区小说| 精品视频偷偷看在线观看| 亚洲色图狂野欧美| 亚洲欧美激情一区| 91av在线播放| 国产精品久久久久久影视| 中文字幕av一区中文字幕天堂| 欧美在线视频导航| 97国产精品免费视频| 富二代精品短视频| 日韩av网址在线| 成人h片在线播放免费网站| 成人性生交xxxxx网站| 国产91露脸中文字幕在线| 久久好看免费视频| 亚洲四色影视在线观看| 97精品久久久中文字幕免费| 日韩欧美中文免费| 久久精品视频在线播放| 97超碰蝌蚪网人人做人人爽| 亚洲va欧美va国产综合久久| 亚洲第一页在线| 亚洲三级黄色在线观看| 黄网动漫久久久| 欧洲成人性视频| 日韩av免费一区| 久久久精品中文字幕| 久久夜精品va视频免费观看| 日本a级片电影一区二区| 91av免费观看91av精品在线| 久久精品国产电影| 茄子视频成人在线| 国产精品夫妻激情| 国产一区二区三区三区在线观看| 日韩av影视综合网| 亚洲电影免费观看高清| xvideos国产精品| 国产精品偷伦一区二区| 国产精品国产三级国产aⅴ浪潮| 日本国产欧美一区二区三区| 久久久91精品| 国产精品爱久久久久久久| 欧美国产日韩一区二区| 在线日韩欧美视频| 久久久亚洲国产天美传媒修理工| 国产精品国产福利国产秒拍| 亚洲高清不卡av| 久久影院资源网| 日韩美女在线看| 日韩av手机在线看| 日韩在线观看免费网站| 精品久久久一区二区| 国产高清视频一区三区| 91精品在线影院| 欧美精品videossex性护士| 4438全国亚洲精品在线观看视频| 欧美一级片在线播放| 久久久精品一区| 欧美在线视频a| 亚洲欧美日韩精品久久亚洲区| 日本国产一区二区三区| 一区二区在线免费视频| 亚洲精品午夜精品| 尤物九九久久国产精品的分类| 色青青草原桃花久久综合| 久久五月天综合| 欧美成人免费小视频| 久久久久中文字幕| 一个人看的www久久| 国内偷自视频区视频综合| 91热福利电影| 成人h片在线播放免费网站| 亚洲一区二区三区久久| 欧洲精品在线视频| 成人黄色网免费| 91中文字幕在线| 欧美一级淫片播放口| 久99久在线视频| 欧美在线免费观看| 色综合视频一区中文字幕| 日本午夜人人精品| 伊人伊成久久人综合网小说| 成人自拍性视频| 欧美另类极品videosbestfree| 欧美午夜片欧美片在线观看| 成人写真福利网| 亚洲三级黄色在线观看| 国产不卡视频在线| 亚洲国产精品va在线看黑人动漫| 欧美精品激情blacked18| 久久精品最新地址| 国产成人精品一区二区三区| 欧美激情在线有限公司| 久久精彩免费视频| 日韩欧美中文字幕在线播放| 黑人精品xxx一区一二区| 国产精品一区二区av影院萌芽| 91在线中文字幕| 一本色道久久88亚洲综合88| 欧美日韩国产黄| 欧美日韩999| 亚洲日本成人网| 久久人人爽亚洲精品天堂| 亚洲已满18点击进入在线看片| 亚洲欧美日韩在线一区| 亚洲а∨天堂久久精品9966| 国产欧美日韩丝袜精品一区| 久久精品人人做人人爽| 国产综合视频在线观看| 国产精品私拍pans大尺度在线| 日韩免费在线观看视频| 亚洲免费成人av电影| 亚洲成人久久久久| 欧美日韩日本国产| 法国裸体一区二区| 亚州国产精品久久久| 欧美大秀在线观看| 亚洲片在线观看| 国产婷婷成人久久av免费高清| 91亚洲精品在线| 69av成年福利视频| 欧美福利视频在线| 欧美成人自拍视频| 国产精品69久久| 久久亚洲精品一区| 91精品久久久久| 日韩欧美在线视频免费观看| 菠萝蜜影院一区二区免费| 亚洲最新在线视频|