1.下载nginx
下载地址:http://nginx.org/en/download.html
2.上传到指定目录下并解压
3.配置
- ./configure --prefix=/usr/local/nginx
显示如下结果:
+ Linux 3.10.0-693.el7.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
错误原因:没有安装gcc
解决:yum install gcc
- ./configure --prefix=/usr/local/nginx
显示如下结果:
./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.
./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或pece-devel
解决:yum install pcre pece-devel
- ./configure --prefix=/usr/local/nginx
显示如下结果:
./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 zlib-devel
解决:yum install zlib zlib-devel
- ./configure --prefix=/usr/local/nginx
显示如下结果:
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
如果想使用openssl 功能,sha1 功能就需要安装openssl ,sha1。
yum -y install openssl openssl-devel
开启ssl 模块
./configure --with-http_ssl_module
- make && make install
4.启动nginx
cd /usr/local/nginx/下看到如下目录
conf--nginx配置文件
html--网页文件
logs--日志文件
nginx-1.14.0--ngxin解压后文件
sbin--二进制程序
./usr/local/nginx/sbin/nginx
ps:启动可能会报错
nginx启动使用80端口,如果有服务占用了80端口可能导致nginx启动失败。
显示所有TCP传输协议的连线状况:netstat -antp
停止相应服务即可。