centos下安装nginx

本人qq群也有许多的技术文档,希望可以为你提供一些帮助(非技术的勿加)。

QQ群:   281442983 (点击链接加入群:http://jq.qq.com/?_wv=1027&k=29LoD19)    QQ:1542385235

1、到 http://nginx.org/en/download.html 下载稳定版(Stable version)。

wget http://nginx.org/download/nginx-1.8.1.tar.gz

2、解压进入目录

1
2
tar zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1

3、 执行 configure

./configure

报错:

./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.

安装 PCRE:

1
yum -y install pcre-devel

再次执行 configure

报错:

1
2
3
4
./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.

 安装zlib-devel:

1
yum -y install zlib-devel

 再次执行 configure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + using system zlib library
 
  nginx path prefix: "/usr/local/nginx"
  nginx binary file"/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file"/usr/local/nginx/conf/nginx.conf"
  nginx pid file"/usr/local/nginx/logs/nginx.pid"
  nginx error log file"/usr/local/nginx/logs/error.log"
  nginx http access log file"/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

提示 OpenSSL、sha1没有找到。

安装 openssl:

1
yum -y install openssl openssl-devel

找到openssl安装路径

1
whereis openssl

再次执行 configure

1
./configure --with-openssl=/usr/include/openssl/

结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Configuration summary
  + using system PCRE library
  + using OpenSSL library: /usr/include/openssl/
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library
 
  nginx path prefix: "/usr/local/nginx"
  nginx binary file"/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file"/usr/local/nginx/conf/nginx.conf"
  nginx pid file"/usr/local/nginx/logs/nginx.pid"
  nginx error log file"/usr/local/nginx/logs/error.log"
  nginx http access log file"/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

4、编译,安装。

1
make && make install

 5、启动

1
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 6、查看进程是否启动

1
ps -ef | grep nginx

 结果:

1
2
3
root     11548     1  0 12:34 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody   11549 11548  0 12:34 ?        00:00:00 nginx: worker process                                         
root     11572 11558  0 12:36 pts/1    00:00:00 grep nginx

 7、其它

nginx中文手册

本人qq群也有许多的技术文档,希望可以为你提供一些帮助(非技术的勿加)。

QQ群:   281442983 (点击链接加入群:http://jq.qq.com/?_wv=1027&k=29LoD19)    QQ:1542385235

 

我的淘宝店,可以进去逛逛噢:https://shop108912636.taobao.com/index.htm?spm=2013.1.w5001-7867000954.3.1d29318dPlLar7&scene=taobao_shop

 

posted @ 2016-03-10 16:07  piwenfei  阅读(1115)  评论(0编辑  收藏  举报