nginx web服務基礎搭建

2021-07-25 04:58:52 字數 3092 閱讀 2418

(1)編譯安裝nginx服務以及關聯rpm包;

a.安裝pcre pcre-devel

yum install pcre pcre-devel -y

檢視pcre pcre-devel

[root@mobana conf]#rpm -qa pcre pcre-devel

pcre-7.8-7.el6.x86_64

pcre-devel-7.8-7.el6.x86_64

b.安裝openssl openssl-devel

yum installopenssl openssl-devel -y

檢視openssl openssl-devel

[root@mobana conf]#rpm -qa openssl openssl-devel

openssl-1.0.1e-48.el6_8.3.x86_64

openssl-devel-1.0.1e-48.el6_8.3.x86_64

mkdir -p /home/klaus/tools

cd /home/klaus/tools

wget -q 

useradd nginx -s /sbin/nologin -m

tar xf nginx-1.6.3.tar.gz

cd nginx-1.6.3

make

make install

<== 建立軟鏈結

(2)建立檔案目錄及關聯檔案;

[root@mobana conf]# tree ../conf/

../conf/

|-- extra

|   |-- bbs.conf

|   |-- blog.conf

|   |-- status.conf    

<== 建立extra目錄,在目錄下建立各分站點配置檔案,這個檔案用於監控nginx服務是否正常使用;

|   `-- www.conf

|-- fastcgi.conf

|-- fastcgi.conf.default

|-- fastcgi_params

|-- fastcgi_params.default

|-- koi-utf

|-- koi-win

|-- mime.types

|-- mime.types.default

|-- nginx.conf        <== nginx主配置檔案;

|-- nginx.conf_basename

|-- nginx.conf.default  <== 主配置檔案備份檔案,與nginx初始配置檔案相同;

|-- scgi_params

|-- scgi_params.default

|-- uwsgi_params

|-- uwsgi_params.default

`-- win-utf

[root@mobana conf]# tree ../html/

../html/

|-- 50x.html

|-- bbs

|   `-- index.html

<== 分站點根檔案

|-- blog

|   `-- index.html    

<== 分站點根檔案

`-- www

`-- index.html

<== 分站點根檔案

(3)配置nginx主配置檔案;

[root@mobana conf]# cat -n nginx.conf

1  worker_processes  1;

2  error_log logs/error.log error;

<== nginx錯誤日誌,級別error;

11                      '"$http_user_agent" "$http_x_forwarded_for" '; <== 訪問日誌的引數;日誌級別main;

12      sendfile        on;

13      keepalive_timeout  65;

14  include extra/www.conf;

15  include extra/bbs.conf;      

<==nginx主檔案精簡優化;

16  include extra/blog.conf;

17  include extra/status.conf;

<== 

nginx狀態資訊功能;

18  }

[root@mobana conf]# cat -n extra/www.conf

1      server

8       access_log logs/access_www.log main gzip buffer=32k flush=5s;  <== www訪問日誌,級別main;

9     }

[root@mobana conf]# cat -n extra/bbs.conf

1      server

8        access_log logs/access_bbs.log main gzip buffer=32k flush=5s;  <== bbs訪問日誌,級別main;

9     }

[root@mobana conf]# cat -n extra/blog.conf

1      server

8        access_log logs/access_blog.log main gzip buffer=32k flush=5s;  <== blog訪問日誌,級別main;

9     }

[root@mobana conf]# cat -n extra/status.conf

1  ##status

2  server

9     access_log logs/access_status.log main gzip buffer=32k flush=5s;  <== status監控日誌,級別main;

Nginx Web服務應用

nginx下面用原始碼安裝nginx tar zxf nginx 1.12.0.tar.gz cd nginx 1.12.0 cd mnt nginx 1.12.0 vim src core nginx.h 隱藏nginx使用的版本號 yum install pcre devel openssl d...

nginx web伺服器配置

定義nginx執行的使用者和使用者組 user www www nginx程序數,建議設定為等於cpu總核心數。worker processes 8 全域性錯誤日誌定義型別,debug info notice warn error crit error log ar loginx error.log...

nginx web伺服器部署

一.什麼是web伺服器 圖1是web伺服器的工作原理,可見其根本工作就是接收資料 傳送資料和資料處理,高階的伺服器就是將這三個部分更加細緻的設計。nginx就是這樣一款高效能伺服器,由俄羅斯工程師igor sysoev為俄羅斯訪問量第二的rambler.ru站點開發,它的主要功能有 http伺服器 ...