linux下安装nginx出错,Linux 下安装nginx的总结 (之前写的有问题))

1. 下载niginx的 tar包

下载路径

http://nginx.org/en/download.html

也可以直接使用命令下载

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

2. 下载目录下解压缩

tar -zxvf nginx-1.15.1.tar.gz

3. cd 到目录里面进行处理

./configure

4. 安装时会报错 主要有:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module byusing --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

staticallyfrom the source with nginx by using --with-pcre=option.

需要pcre

./configure: error: the HTTP gzip module requires the zlib library.

You can either disable the module byusing --without-http_gzip_module

option, or install the zlib library into the system, or build the zlib library

staticallyfrom the source with nginx by using --with-zlib=option.

需要zlib

一般linux里面安装了 prce和 zlib 但是没有安装devel 包 需要进行安装

yum install -y prce-devel

yum install-y zlib-devel

5. 再次执行 ./confiure命令成功

反馈安装信息

Configuration summary+ usingsystem PCRE library+ OpenSSL library isnot used+ usingsystem zlib library

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"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"

6. 执行 make 和 make install 进行安装

make and make install

9. 创建软连接

ln /usr/local/nginx/sbin/nginx /usr/local/bin/nginx

10. 直接启动

nginx

遇到报错如图示时

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already inuse)

nginx: [emerg] bind() to0.0.0.0:80 failed (98: Address already inuse)

nginx: [emerg] bind() to0.0.0.0:80 failed (98: Address already inuse)

nginx: [emerg] bind() to0.0.0.0:80 failed (98: Address already inuse)

nginx: [emerg] bind() to0.0.0.0:80 failed (98: Address already inuse)

nginx: [emerg] still could not bind()

11. 修改配置文件

查看配置文件位置

nginx-t

结果为

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

修改配置文件

vim /usr/local/nginx/conf/nginx.conf

将端口绑定修改一下

d54892138ecbe46ce66fad3bc13f9756.png

再次启动即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值