欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

三步配置輕量級服務(wù)器nginx小結(jié)

 更新時間:2023年08月20日 11:46:19   作者:YT20233  
Nginx是一個安裝非常的簡單 , 配置文件非常簡潔,本文就來介紹一下三步配置輕量級服務(wù)器nginx,具有一定的參考價值,感興趣的可以了解一下

一 nginx及其應(yīng)用場景

1.什么是nginx

一款輕量級的Web服務(wù)器,反向代理服務(wù)器,以及電子郵件代理服務(wù)器

主要有三個優(yōu)點(diǎn):

  • 占用內(nèi)存少,并發(fā)能力強(qiáng)
  • Nginx為性能優(yōu)化開發(fā),能支持五千個左右的并發(fā)響應(yīng)
  • (Tomcat只有三百到五百)
  • Nginx支持熱部署,可以在不間斷服務(wù)情況下對軟件進(jìn)行升級(不要用關(guān)閉服務(wù)器)

2.應(yīng)用場景背誦

  • 靜態(tài)http服務(wù)器,可以獨(dú)立提供靜態(tài)http服務(wù)
  • 虛擬主機(jī):在一臺服務(wù)器虛擬出多個網(wǎng)站
  • 反向代理:網(wǎng)站訪問量到達(dá)一定程度后,單臺服務(wù)器已經(jīng)無法完成所有的訪問量,需要用nginx實(shí)現(xiàn)反向代理
  • 負(fù)載均衡:每個服務(wù)器承擔(dān)一定的資源,不會出現(xiàn)一個服務(wù)器承擔(dān)過多的服務(wù)導(dǎo)致宕機(jī),而另一個服務(wù)器閑置的情況下

二 nginx的配置安裝

1.選擇nginx版本

下載nginx, 官方網(wǎng)站:http://nginx.org/en/download.html

我們使用的版本是1.17.8版本。 Nginx在Linux下安裝,只提供了源代碼,所以我們需要進(jìn)行編譯.

2. 安裝配置環(huán)境

需要安裝gcc的環(huán)境。執(zhí)行命令:

yum install gcc-c++
[root@localhost ~]# yum install gcc-c++
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.njupt.edu.cn
base                                                                                                         | 3.6 kB  00:00:00     
extras                                                                                                       | 2.9 kB  00:00:00     
updates                                                                                                      | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                                                  |  20 MB  00:00:05     
正在解決依賴關(guān)系

安裝PCRE依賴

nginx的http模塊使用pcre來解析正則表達(dá)式,所以需要在linux上安裝pcre庫

[root@localhost ~]# yum install -y pcre pcre-devel
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.njupt.edu.cn
軟件包 pcre-8.32-17.el7.x86_64 已安裝并且是最新版本
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 pcre-devel.x86_64.0.8.32-17.el7 將被 安裝
--> 解決依賴關(guān)系完成

nginx使用zlib對http包的內(nèi)容進(jìn)行g(shù)zip,所以需要在linux上安裝zlib庫。

[root@localhost ~]# yum install -y zlib zlib-devel
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.njupt.edu.cn
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 zlib.x86_64.0.1.2.7-18.el7 將被 升級
---> 軟件包 zlib.x86_64.0.1.2.7-21.el7_9 將被 更新
---> 軟件包 zlib-devel.x86_64.0.1.2.7-21.el7_9 將被 安裝
--> 解決依賴關(guān)系完成

OpenSSL 是一個強(qiáng)大的安全套接字層密碼庫,nginx不僅支持http協(xié)議,還支持https,所以需要在linux安裝openssl庫。

[root@localhost ~]# yum install -y openssl openssl-devel
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.njupt.edu.cn
正在解決依賴關(guān)系
--> 正在檢查事務(wù)
---> 軟件包 openssl.x86_64.1.1.0.2k-19.el7 將被 升級
---> 軟件包 openssl.x86_64.1.1.0.2k-26.el7_9 將被 更新
--> 正在處理依賴關(guān)系 openssl-libs(x86-64) = 1:1.0.2k-26.el7_9,它被軟件包 1:openssl-1.0.2k-26.el7_9.x86_64 需要
---> 軟件包 openssl-devel.x86_64.1.1.0.2k-26.el7_9 將被 安裝
--> 正在處理依賴關(guān)系 krb5-devel(x86-64),它被軟件包 1:openssl-devel-1.0.2k-26.el7_9.x86_64 需要
--> 正在檢查事務(wù)
---> 軟件包 krb5-devel.x86_64.0.1.15.1-55.el7_9 將被 安裝
--> 正在處理依賴關(guān)系 libkadm5(x86-64) = 1.15.1-55.el7_9,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
--> 正在處理依賴關(guān)系 krb5-libs(x86-64) = 1.15.1-55.el7_9,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
--> 正在處理依賴關(guān)系 libverto-devel,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
--> 正在處理依賴關(guān)系 libselinux-devel,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
--> 正在處理依賴關(guān)系 libcom_err-devel,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
--> 正在處理依賴關(guān)系 keyutils-libs-devel,它被軟件包 krb5-devel-1.15.1-55.el7_9.x86_64 需要
---> 軟件包 openssl-libs.x86_64.1.1.0.2k-19.el7 將被 升級
---> 軟件包 openssl-libs.x86_64.1.1.0.2k-26.el7_9 將被 更新
--> 正在檢查事務(wù)
---> 軟件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 將被 安裝
---> 軟件包 krb5-libs.x86_64.0.1.15.1-50.el7 將被 升級
---> 軟件包 krb5-libs.x86_64.0.1.15.1-55.el7_9 將被 更新
---> 軟件包 libcom_err-devel.x86_64.0.1.42.9-19.el7 將被 安裝
---> 軟件包 libkadm5.x86_64.0.1.15.1-55.el7_9 將被 安裝
---> 軟件包 libselinux-devel.x86_64.0.2.5-15.el7 將被 安裝
--> 正在處理依賴關(guān)系 libsepol-devel(x86-64) >= 2.5-10,它被軟件包 libselinux-devel-2.5-15.el7.x86_64 需要
--> 正在處理依賴關(guān)系 pkgconfig(libsepol),它被軟件包 libselinux-devel-2.5-15.el7.x86_64 需要
---> 軟件包 libverto-devel.x86_64.0.0.2.5-4.el7 將被 安裝
--> 正在檢查事務(wù)
---> 軟件包 libsepol-devel.x86_64.0.2.5-10.el7 將被 安裝
--> 解決依賴關(guān)系完成

把它放到root目錄下

3.安裝nginx

tar -xvf nginx-1.17.8.tar
[root@localhost ~]# ll
總用量 6420
-rw-------. 1 root root    1234 4月  15 20:38 anaconda-ks.cfg
drwxrwxrwx. 2 root root      20 4月  18 17:45 for
-rw-r--r--. 1 root root 6569984 4月  24 20:51 nginx-1.17.8.tar
[root@localhost ~]# tar -xvf nginx-1.17.8.tar
nginx-1.17.8/
nginx-1.17.8/auto/
nginx-1.17.8/conf/
nginx-1.17.8/contrib/
nginx-1.17.8/src/
nginx-1.17.8/configure
nginx-1.17.8/LICENSE
nginx-1.17.8/README
nginx-1.17.8/html/
nginx-1.17.8/man/
nginx-1.17.8/CHANGES.ru
nginx-1.17.8/CHANGES

查看解壓的包

[root@localhost ~]# ll
總用量 6420
-rw-------. 1 root root    1234 4月  15 20:38 anaconda-ks.cfg
drwxrwxrwx. 2 root root      20 4月  18 17:45 for
drwxr-xr-x. 8 1001 1001     158 1月  21 2020 nginx-1.17.8
-rw-r--r--. 1 root root 6569984 4月  24 20:51 nginx-1.17.8.tar

4 進(jìn)入目錄內(nèi)

[root@localhost ~]# cd nginx-1.17.8
[root@localhost nginx-1.17.8]# ll
總用量 764
drwxr-xr-x. 6 1001 1001   4096 4月  24 20:54 auto
-rw-r--r--. 1 1001 1001 301950 1月  21 2020 CHANGES
-rw-r--r--. 1 1001 1001 460775 1月  21 2020 CHANGES.ru
drwxr-xr-x. 2 1001 1001    168 4月  24 20:54 conf
-rwxr-xr-x. 1 1001 1001   2502 1月  21 2020 configure
drwxr-xr-x. 4 1001 1001     72 4月  24 20:54 contrib
drwxr-xr-x. 2 1001 1001     40 4月  24 20:54 html
-rw-r--r--. 1 1001 1001   1397 1月  21 2020 LICENSE
drwxr-xr-x. 2 1001 1001     21 4月  24 20:54 man
-rw-r--r--. 1 1001 1001     49 1月  21 2020 README
drwxr-xr-x. 9 1001 1001     91 4月  24 20:54 src

執(zhí)行命令 configure,生成mikefile文件

./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi

搞定配置

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/var/run/nginx/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/temp/nginx/client"
  nginx http proxy temporary files: "/var/temp/nginx/proxy"
  nginx http fastcgi temporary files: "/var/temp/nginx/fastcgi"
  nginx http uwsgi temporary files: "/var/temp/nginx/uwsgi"
  nginx http scgi temporary files: "/var/temp/nginx/scgi"

生成了一個makefile文件

[root@localhost nginx-1.17.8]# ll
總用量 768
drwxr-xr-x. 6 1001 1001   4096 4月  24 20:54 auto
-rw-r--r--. 1 1001 1001 301950 1月  21 2020 CHANGES
-rw-r--r--. 1 1001 1001 460775 1月  21 2020 CHANGES.ru
drwxr-xr-x. 2 1001 1001    168 4月  24 20:54 conf
-rwxr-xr-x. 1 1001 1001   2502 1月  21 2020 configure
drwxr-xr-x. 4 1001 1001     72 4月  24 20:54 contrib
drwxr-xr-x. 2 1001 1001     40 4月  24 20:54 html
-rw-r--r--. 1 1001 1001   1397 1月  21 2020 LICENSE
-rw-r--r--. 1 root root    355 4月  24 21:01 Makefile
drwxr-xr-x. 2 1001 1001     21 4月  24 20:54 man
drwxr-xr-x. 3 root root    125 4月  24 21:01 objs
-rw-r--r--. 1 1001 1001     49 1月  21 2020 README
drwxr-xr-x. 9 1001 1001     91 4月  24 20:54 src

make

開始編譯

[root@localhost nginx-1.17.8]# make
make -f objs/Makefile
make[1]: 進(jìn)入目錄“/root/nginx-1.17.8”
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/nginx.o \
	src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_log.o \
	src/core/ngx_log.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_palloc.o \
	src/core/ngx_palloc.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_array.o \
	src/core/ngx_array.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_list.o \
	src/core/ngx_list.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_hash.o \
	src/core/ngx_hash.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_buf.o \
	src/core/ngx_buf.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
	-o objs/src/core/ngx_queue.o \
	src/core/ngx_queue.c

正式安裝

make install 

安裝到了usr的local目錄下

cp conf/scgi_params \
	'/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
	|| cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/var/run/nginx' \
	|| mkdir -p '/var/run/nginx'
test -d '/var/log/nginx' \
	|| mkdir -p '/var/log/nginx'
test -d '/usr/local/nginx/html' \
	|| cp -R html '/usr/local/nginx'
test -d '/var/log/nginx' \
	|| mkdir -p '/var/log/nginx'
make[1]: 離開目錄“/root/nginx-1.17.8”
[root@localhost nginx-1.17.8]# 

查看安裝

[root@localhost nginx-1.17.8]# cd /usr/local
[root@localhost local]# ll
總用量 0
drwxr-xr-x. 2 root root  6 4月  11 2018 bin
drwxr-xr-x. 2 root root  6 4月  11 2018 etc
drwxr-xr-x. 2 root root  6 4月  11 2018 games
drwxr-xr-x. 2 root root  6 4月  11 2018 include
drwxr-xr-x. 2 root root  6 4月  11 2018 lib
drwxr-xr-x. 2 root root  6 4月  11 2018 lib64
drwxr-xr-x. 2 root root  6 4月  11 2018 libexec
drwxr-xr-x. 5 root root 42 4月  24 21:04 nginx
drwxr-xr-x. 2 root root  6 4月  11 2018 sbin
drwxr-xr-x. 5 root root 49 4月  15 20:34 share
drwxr-xr-x. 2 root root  6 4月  11 2018 src

4.啟動nginx

[root@localhost local]# cd nginx/
[root@localhost nginx]# ll
總用量 4
drwxr-xr-x. 2 root root 4096 4月  24 21:04 conf
drwxr-xr-x. 2 root root   40 4月  24 21:04 html
drwxr-xr-x. 2 root root   19 4月  24 21:04 sbin

sbin目錄下放了一些可執(zhí)行文件

執(zhí)行啟動命令

root@localhost nginx]# cd sbin/
[root@localhost sbin]# ll
總用量 3792
-rwxr-xr-x. 1 root root 3881416 4月  24 21:04 nginx
[root@localhost sbin]# ./nginx

查看進(jìn)程是否啟動了

[root@localhost sbin]# ps aux | grep nginx
root       4737  0.0  0.0  20564   616 ?        Ss   21:11   0:00 nginx: master process ./nginx
nobody     4738  0.0  0.0  21000  1316 ?        S    21:11   0:00 nginx: worker process
root       4741  0.0  0.0 112824   980 pts/0    R+   21:13   0:00 grep --color=auto nginx

三 訪問

在瀏覽器輸入自己的虛擬機(jī)ip+端口號

./nginx -s stop 關(guān)閉
./nginx -s reload 重啟

到此這篇關(guān)于三步配置輕量級服務(wù)器nginx小結(jié)的文章就介紹到這了,更多相關(guān)配置輕量級nginx服務(wù)器內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • nginx如何限制訪問某些url

    nginx如何限制訪問某些url

    這篇文章主要關(guān)于介紹了nginx如何限制訪問某些url的相關(guān)資料,nginx是非常出色web服務(wù)器,對于靜態(tài)文件的處理非常高效,同時它的代理轉(zhuǎn)發(fā)功能和其它后臺服務(wù)器搭配起來也非常的簡單高效,需要的朋友可以參考下
    2023-08-08
  • nginx basic認(rèn)證的實(shí)現(xiàn)示例

    nginx basic認(rèn)證的實(shí)現(xiàn)示例

    auth_basic作為一個認(rèn)證模塊,在apache和nginx中都很常用,本文主要介紹了nginx basic認(rèn)證的實(shí)現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下
    2024-08-08
  • nginx設(shè)置X-Frame-Options的字段選擇

    nginx設(shè)置X-Frame-Options的字段選擇

    本文主要介紹了X-Frame-Options選項(xiàng)的三個值,包含DENY、SAMEORIGIN和ALLOW-FROM uri,具有一定的參考價值,感興趣的可以了解一下
    2024-12-12
  • Nginx服務(wù)啟動和停止實(shí)現(xiàn)

    Nginx服務(wù)啟動和停止實(shí)現(xiàn)

    使用Nginx的過程中,我們可能總是需要修改nginx配置文件,然后不停地啟動或者停止nginx服務(wù),本文就來介紹一下,感興趣的可以了解一下
    2023-11-11
  • nginx反向代理java項(xiàng)目方式

    nginx反向代理java項(xiàng)目方式

    文章簡要介紹了如何使用Nginx作為反向代理來部署Java項(xiàng)目,核心在于配置proxy_pass指令
    2024-12-12
  • nginx安裝以及配置的詳細(xì)過程記錄

    nginx安裝以及配置的詳細(xì)過程記錄

    Nginx (engine x) 是一個高性能的HTTP和反向代理服務(wù)器,也是一個IMAP/POP3/SMTP服務(wù)器,下面這篇文章主要給大家介紹了關(guān)于nginx安裝以及配置的詳細(xì)過程,文章將實(shí)現(xiàn)的過程介紹的非常詳細(xì),需要的朋友可以參考下
    2021-09-09
  • 利用Nginx_geo模塊實(shí)現(xiàn)CDN調(diào)度的配置方法

    利用Nginx_geo模塊實(shí)現(xiàn)CDN調(diào)度的配置方法

    今天小編就為大家分享一篇利用Nginx_geo模塊實(shí)現(xiàn)CDN調(diào)度的配置方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • Nginx+Windows搭建域名訪問環(huán)境的操作方法

    Nginx+Windows搭建域名訪問環(huán)境的操作方法

    這篇文章主要介紹了Nginx搭建域名訪問環(huán)境,包括nginx配置文件的相關(guān)介紹及對nginx配置文件的分析,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-03-03
  • Nginx之QPS限制模塊的具體使用

    Nginx之QPS限制模塊的具體使用

    本文主要介紹了Nginx之QPS限制模塊的具體使用,主要介紹Nginx QPS限制模塊的原理、安裝和使用方法,具有一定的參考價值,感興趣的可以了解一下
    2023-09-09
  • Nginx配置SSL證書監(jiān)聽443端口

    Nginx配置SSL證書監(jiān)聽443端口

    這篇文章主要為大家詳細(xì)介紹了Nginx配置SSL證書監(jiān)聽443端口的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-02-02

最新評論