nginx安装

2010阅读 0评论2015-12-16 Niel_Rabbit
分类:Web开发

相信通过google,大家一定能顺利的安装nginx。这里记录一下我的安装过程:
=============================================================================================================
安装环境
Prepare package:
=============================================================================================================
安装过程
1)编译安装openssl, pcre已经zlib这三个的安装类似,这里取openssl为例,其他类似
# tar -zxvf openssl-1.0.2e.tar.gz
# cd openssl-1.0.2e
# ./config --prefix=/usr/local/openssl_1_0_2e
# make
# make install


2) 编译安装nginx
# tar -zxvf nginx-1.8.0.tar.gz
# cd nginx-1.8.0
# ./configure --prefix=/usr/local/nginx_1_8_0 --with-http_ssl_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.2e --with-http_stub_status_module
# make
# make install

在nginx的configure过程中指定了一些选项:
--with-http_ssl_module
#启用支持https模块
--with-pcre=../pcre-8.37
#指向解压的源码目录
--with-zlib=../zlib-1.2.8
#指向解压的源码目录
--with-openssl=../openssl-1.0.2e
#指向解压的源码目录
--with-http_stub_status_module
#启用 nginx 的 NginxStatus 功能,用来监控 Nginx 的当前状态

 

 
 

 

 


如若安装了相应库,可不指定库路径的选项。若安装时找不到上述依赖模块,就请使用--with-openssl=、--with-pcre=、--with-zlib=指定依赖的模块目录。如已安装过,此处的路径为安装目录;若未安装,则此处路径为编译安装包路径,nginx将执行模块的默认编译安装。

==========================================================
===================================================
启动运行

在本文中,nginx将会安装到/usr/local/nginx_1_8_0下:
# cd /usr/local/nginx_1_8_0/sbin/
# ./nginx    #运行nginx

# netstat -tlnp|grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      15966/nginx

此时nginx服务已经启动,打开你的浏览器,输入http://[IP]/ 就可以看到:

Welcome to nginx!

上一篇:nginx学习之基本概念
下一篇:服务器程序编写应该注意哪些