Centos 安裝Nginx

一 安裝編譯工具及庫文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

二 安裝 PCRE (支持Rewrite 功能)

# 下載地址: http://www.pcre.org
wget ftp://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz # 下載,我用的8.43版本
tar -zxvf  pcre-8.43.tar.gz #解壓
cd pcre-8.43/  #進入源碼目錄
./configure    #配置
make  #編譯
make install #安裝

三 安裝nginx

#下載地址: http://nginx.org/
wget http://nginx.org/download/nginx-1.17.5.tar.gz  # 下載,我用的1.17.5版本
tar -zxvf nginx-1.17.5.tar.gz   #解壓
cd nginx-1.17.5/  #進入源碼目錄
 ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/pcre-8.43   # /opt/pcre-8.43是 PCRE源碼目錄  /opt/nginx 是nginx安裝目錄
make  #編譯
make install #安裝

四 驗證安裝

安裝完成後進入 /opt/nginx目錄,nginx可執行程序在sbin`目錄下,進入sbin目錄驗證安裝,

[root@localhost nginx]# ls
client_body_temp  conf  fastcgi_temp  html  logs  proxy_temp  sbin  scgi_temp  uwsgi_temp
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ls
nginx
[root@localhost sbin]# ./nginx  -v   查看nginx
nginx version: nginx/1.17.5
[root@localhost sbin]# ./nginx  -t  # 檢查配置文件
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
[root@localhost sbin]# ./nginx  # 啓動nginx 

啓動nginx 後再瀏覽器輸入電腦ip地址,回車,如果打印出以下信息則證明安裝成功。

Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章