Linux环境下如何安装Nginx及常见问题处理

1.上传Nginx的tar包

首先需要下载Linux系统版本的Nginx安装包,可以从Nginx官网上进行相应版本下载,也可以通过分享的云盘链接下载:链接:链接:https://pan.baidu.com/s/13Gw_NVLTLXXa4mA4EexRdA
提取码:ihkc
链接对应1.8.0版本的Nginx,链接失效或有需要更高版本可私信联系。

2.安装Nginx的依赖

yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

3.创建nginx安装路径

mkdir /usr/local/nginx

3.解压nginx

tar -xvf nginx-1.8.0.tar.gz -C /usr/local/nginx

/**
* 1.在nginx所在的压缩tar包所在的文件夹下运行该命令
* 2."nginx-1.8.0.tar.gz"是nginx的压缩包的名字
*/

4.编译nginx

4.1.进入nginx的文件目录
	cd /usr/local/nginx/nginx-1.8.0
4.2.编译nginx
	./configure
	make
	make install

5.开放nginx的80端口

5.1.开放80端口
	/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
5.2.开放的端口永久保存到防火墙
	/etc/rc.d/init.d/iptables save

6.运行nginx

6.1.进入nginx的运行目录
		cd /usr/local/nginx/sbin
6.2.运行nginx
		./nginx
6.3.关闭
		./nginx -s stop
6.4.重启
		./nginx -s reload

7.常见问题

7.1 缺少PCRE依赖库

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

解决方法:sudo apt-get install libpcre3 libpcre3-dev

7.2 缺少zlib依赖库

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

解决方法:sudo apt-get install zlib1g-dev

7.3 apt-get命令被占用

Could not get lock /var/lib/dpkg/lock - open (11: Resource 
temporarily unavailable) Unable to lock the administration 
directory (/var/lib/dpkg/), is another process using it?

解决方法:找到占用进程,然后kill

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码农辰南

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值