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.
posted @ 2019-11-10 01:19  ay-a  阅读(669)  评论(0编辑  收藏  举报