这文章主要讲一下nginx的安装。
    
     说明:本文章内容已经在
     
      CentOS Linux release 7.3.1611 (Core)
     
     上测试通过。
    
   
访问nginx官网下载适合的nginx版本,使用tar命令解压,进入解压目录执行
./configure在centos7.3执行上面命令会出现如下错误,
错误内容1:
./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.
解决方法:
yum -y install pcre-devel错误内容2:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.解决方法:
yum install -y zlib-devel错误内容23
./configure: error: C compiler cc is not found解决方法:
yum install gcc接着执行
./configure
make
make install安装便可成功。
    进入
    
     /usr/local/nginx/sbin
    
    执行
    
     ./nginx
    
    可以启动nginx,执行
    
     netstat -nlp
    
    可以看到
    
     80
    
    端口已经被监听,在浏览器输入
    
     http://127.0.0.1
    
    可以看到
    
     Welcome to nginx!
    
    表示nginx已经启动成功。
   
    
     nginx环境变量配置
    
   
    每次操作nginx都需要进入
    
     /usr/local/nginx/sbin
    
    目录中,过于繁琐,因此可以在通过配置nginx环境变量解决,如下配置,执行
   
vim /etc/profile打开环境配置文件,
HGINX_HOME=/usr/local/nginx/sbin
PATH=$PATH:$HGINX_HOME:
export PATH
    修改好以后,执行
    
     source /etc/profile
    
    是配置生效。
   
最后附上安装nginx必备的所有的库,如果在编译安装nginx报错的情况下请检查如下库
yum install gcc 
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
    nginx常用命令参考:
    
     http://www.jb51.net/article/47750.htm
    
   
==手机QQ扫描下方二维码,快速加入Java架构师交流群==
     
   
 
