Linux安装Nginx 在线&离线

在线安装

# 下载NGINX:
yum install nginx

# 启动nginx:
systemctl start nginx
# 停止unginx:
systemctl stop nginx
# 加入开机启动:
systemctl enable nginx

# 查看nginx的状态:
systemctl status nginx

离线安装

【yum 安装最新版nginx:https://www.cnblogs.com/xxoome/p/7256214.html
在安装nginx前首先要确认系统中安装了gcc、pcre-devel、zlib-devel、openssl-devel。
Linux下检查是否安装过某软件包:http://www.cnblogs.com/xxoome/p/5866553.html
安装命令:

yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
  1. 下载Nginx
    https://nginx.org/download/
    在这里插入图片描述
  2. 上传至linux
  3. 解压tar -zxvf nginx-1.9.8.tar.gz
  4. 进入Nginx目录执行命令
## 配置
./configure --prefix=/usr/local/nginx

# make
make
make install

踩坑:发现make 报错
在这里插入图片描述
解决地址:https://www.cnblogs.com/wxj612/p/13696628.html

测试是否安装成功

# cd到刚才配置的安装目录
cd /usr/loca/nginx/
./sbin/nginx -t

错误信息:

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)

原因分析:nginx/目录下没有logs文件夹

解决方法:

mkdir logs
chmod 700 logs

正常情况的信息输出:

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

启动nginx

cd /usr/local/nginx/sbin
./nginx //启动nginx

配置nginx开机自启动
编辑文件
vim /etc/rc.d/rc.local
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值