久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

centos中Nginx如何安裝

187次閱讀
沒有評論

共計 4552 個字符,預計需要花費 12 分鐘才能閱讀完成。

這篇文章主要介紹了 centos 中 Nginx 如何安裝,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓丸趣 TV 小編帶著大家一起了解一下。

1、Nginx 服務介紹

  nginx 是一個高性能的 HTTP Server 和代理軟件,它具有高并發、且占用資源少,同時也是一個比較優秀的代理和負載均衡、緩存服務器,它可以運行于多種平臺

官方網站:http://www.nginx.org

2、Nginx 的特點

Web 服務器

高性能的 WEB 服務器軟件,與 Apache 相比,它支持更多的并發連接且占用服務器資源少,效率高

反向代理或負載均衡服務器

作為負載均衡服務器,它可以作為 HTTP SERVER 或 DB 等服務的代理服務器,類似 Haproxy 代理軟件的功能,Nginx 的代理功能相對簡單,效率也不及 Haproxy,同時它也是一個優秀的郵件代理服務軟件

緩存服務器

Nginx 還可以作緩存服務器,類似于專業的緩存軟件功能

3、Nginx 的優點

? 高并發:能支持 1 - 2 萬甚至更多的并發連接(靜態小文件)

? 內存消耗少

? 可以做 HTTP 反向代理——負載均衡的功能

? 內置對集群節點服務器的健康性查功能,不過功能相對較弱

? 通過 cache 插件可以實現緩存軟件能夠實現的功能

4、安裝環境

[root@localhost ~]# cat /etc/redhat-release CentOS release 6.5 (Final)

[root@localhost ~]# uname -r 2.6.32-431.el6.x86_64

5、安裝所需的 pcre 庫

注:安裝這個 pcre 庫是為了讓 nginx 支持 HTTP Rewrite 模塊

創建一個專用的軟件工具目錄(實際生產環境中一定要養成好的規范習慣)

[root@localhost ~]# cd /download/tools/

下載 pcre 軟件

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

編譯安裝

tar zxf pcre-8.38.tar.gz

cd pcre-8.38

./configure

make

make install

6、安裝 Nginx

[root@centos6 tools]# useradd nginx -s /sbin/nologin -M

[root@centos6 tools]# wget http://nginx.org/download/nginx-1.10.1.tar.gz

[root@centos6 tools]# tar zxf nginx-1.10.1.tar.gz 

[root@centos6 tools]# cd nginx-1.10.1

[root@centos6 nginx-1.10.1]# ./configure \

–user=nginx \

–group=nginx \

–prefix=/application/nginx-1.10.1 \

–with-http_stub_status_module \

–with-http_ssl_module

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using –without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using –with-pcre= path option.

[root@centos6 nginx-1.10.1]# ./configure

–user=nginx \

–group=nginx \

–prefix=/application/nginx-1.10.1 \

–with-http_stub_status_module \

–with-http_ssl_module \

–with-pcre=/download/tools/pcre-8.38

注意這里不是安裝后的目錄,而是源碼目錄

[root@centos6 nginx-1.10.1]# make make install

7、啟動服務

建立軟件鏈接

[root@centos6 tools]# ln /application/nginx-1.10.1 /application/nginx

ln: `/application/nginx-1.10.1 : hard link not allowed for directory

看到了吧,這個提示是硬鏈接是不允許的

[root@centos6 tools]# ln -s /application/nginx-1.10.1 /application/nginx 

[root@centos6 tools]# ll /application/nginx

lrwxrwxrwx. 1 root root 25 Nov 28 18:31 /application/nginx – /application/nginx-1.10.1

配置規范啟動

[root@centos6 tools]# cd /application/nginx/conf/

[root@centos6 conf]# cp ../sbin/nginx /etc/init.d/

[root@centos6 conf]# /etc/init.d/nginx

[root@centos6 conf]# ps -ef|grep nginx

root 151771  0 18:33 ?00:00:00 nginx: master process /etc/init.d/nginx

nginx 15178  15177  0 18:33 ?00:00:00 nginx: worker process

root 15180   2340  0 18:33 pts/0 00:00:00 grep nginx

[root@centos6 conf]# lsof -i :80

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

nginx   15177  root    6u  IPv4  26905      0t0  TCP *:http (LISTEN)

nginx   15178 nginx    6u  IPv4  26905      0t0  TCP *:http (LISTEN)

檢查語法

[root@centos6 conf]# /application/nginx/sbin/nginx -t

nginx: the configuration file /application/nginx-1.10.1/conf/nginx.conf syntax is ok

nginx: configuration file /application/nginx-1.10.1/conf/nginx.conf test is successful

有的時候也會提示有錯誤

[root@localhost nginx-1.10.1]# /application/nginx/sbin/nginx -t /application/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

出現錯誤提示 提示說明無法打開 libpcre.so.1 這個文件,沒有這個文件或目錄,出現這個提示的原因是因為在系統的 /etc/ld.so.conf 這個文件里沒有 libpcre.so.1 的路徑配置

解決方法如下:

[root@localhost nginx-1.10.1]# find / -name libpcre.so.1

/download/tools/pcre-8.38/.libs/libpcre.so.1

/usr/local/lib/libpcre.so.1

[root@localhost nginx-1.10.1]# vi /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/local/lib

             # 添加此路徑即可

[root@localhost nginx-1.10.1]# ldconfig

              #生效配置

重新檢查語法

[root@localhost nginx-1.10.1]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.10.1/conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.10.1/conf/nginx.conf test is successful

8、測試服務安裝

centos 中 Nginx 如何安裝
看到這個界面表明安裝是成功的

如果出現無法訪問的現象可以從以下幾個方面排錯

1、防火墻是否關閉

2、與 WEB 服務器的聯通性

3、selinux 是否為 disable

4、telnet 下 80 端口

5、查看錯誤日志記錄進行分析問題所在

9、組建個簡單頁面測試

nginx 的站點目錄如下

[root@centos6 conf]# cd /application/nginx/html/

[root@centos6 html]# ll

total 8

-rw-r–r–. 1 root root 537 Nov 28 18:29 50x.html

-rw-r–r–. 1 root root 612 Nov 28 18:29 index.html

[root@centos6 html]# cp index.html index.html.bak

[root@centos6 html]# vi index.html

!DOCTYPE html

html

head

title Welcome to mingongge s blog! /title

style

    body {

        width: 35em;

        margin: 0 auto;

        font-family: Tahoma, Verdana, Arial, sans-serif;

    }

/style

/head

body

h2 Welcome to mingongge s blog! /h2

p this blog is mingongge s blog!!. /p

p For online documentation and support please refer to

a href= http://www.mingongge.com/ www.mingongge.com /a . br/

Commercial support is available at

a href= http://www.mingongge.com/ www.mingongge.com /a . /p

p em welcome to mingongge s blog. /em /p

/body

/html

centos 中 Nginx 如何安裝

至此 Nginx 服務安裝與配置整個過程結束

感謝你能夠認真閱讀完這篇文章,希望丸趣 TV 小編分享的“centos 中 Nginx 如何安裝”這篇文章對大家有幫助,同時也希望大家多多支持丸趣 TV,關注丸趣 TV 行業資訊頻道,更多相關知識等著你來學習!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-25發表,共計4552字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 辽阳市| 永和县| 盐山县| 禄丰县| 云梦县| 南平市| 盐池县| 咸宁市| 馆陶县| 张北县| 布拖县| 运城市| 博白县| 达孜县| 镇原县| 乌什县| 定兴县| 九龙坡区| 清镇市| 正定县| 阆中市| 星子县| 新沂市| 通许县| 沙雅县| 方正县| 拜泉县| 绥化市| 定结县| 如皋市| 宁都县| 邯郸县| 温宿县| 泊头市| 天门市| 兴隆县| 林周县| 武川县| 抚远县| 论坛| 探索|