您的位置:首页 > 运维架构 > Nginx

CentOS6.5下源码安装 Nginx

2018-02-11 16:26 369 查看
写在前面:

建议先大体看一遍,然后再根据实际情况安装。

1、下载nginx源码

nginx源码下载地址:http://nginx.org/en/download.html



选择需求的版本,右击复制链接,然后使用wget命令下载

//我的下载目录是 /usr/local/src/
//我是用的版本是最新稳定版nginx-1.12.2
[root@localhost src]# wget http://nginx.org/download/nginx-1.12.2.tar.gz[/code] 
2、解压源码

tar -zxvf nginx-1.12.2.tar.gz


3、配置源码

[root@localhost src]# cd nginx-1.12.2
[root@localhost nginx-1.12.2]# ./configure


此处我这里出现了错误:

checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found


解决方法->http://blog.csdn.net/xinyflove/article/details/79310996

再次配置

[root@localhost nginx-1.12.2]# ./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-devel解决问题(作用是让ngnix支持rewrite功能)

yum -y install pcre-devel


再次配置

[root@localhost nginx-1.12.2]# ./configure


又出现一个错误

./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解决问题

yum -y install zlib-devel


再次配置

[root@localhost nginx-1.12.2]# ./configure


这次没有错误提示了,配置成功。

返回 配置概述 信息:

Configuration summary //配置概述
+ using system PCRE library //使用系统PCRE库
+ OpenSSL library is not used //不使用OpenSSL库
+ using system zlib library //使用系统zlib库

nginx path prefix: "/usr/local/nginx" //安装目录
nginx binary file: "/usr/local/nginx/sbin/nginx" //二进制文件
nginx modules path: "/usr/local/nginx/modules" //模块目录
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" //pid文件
nginx error log file: "/usr/local/nginx/logs/error.log" //错误日志文件
nginx http access log file: "/usr/local/nginx/logs/access.log" //http权限日志文件
nginx http client request body temporary files: "client_body_temp" //http客户机请求主体临时文件
nginx http proxy temporary files: "proxy_temp" //http代理临时文件
nginx http fastcgi temporary files: "fastcgi_temp" //http fastcgi临时文件
nginx http uwsgi temporary files: "uwsgi_temp" //http uwsgi临时文件
nginx http scgi temporary files: "scgi_temp" //http scgi临时文件


Tip:

如果需要安装openssl(https支持)

//安装openssl
yum -y install openssl openssl-devel
//然后在进行配置。
./configure


4、安装 make && make install

[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# make install


没有错误提示,安装成功。

5、启动nginx

/usr/local/nginx/sbin/nginx




其他nginx命令

/usr/local/nginx/sbin/nginx -s reload
/usr/local/nginx/sbin/nginx -s stop
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: