奶奶都能学会的Linux系统nginx安装详细过程

Nginx的优点包括:
性能高效,适合高并发环境
资源消耗低,适合资源受限的环境
配置简单,易于理解和修改
轻量级,占用较少内存
可靠性高,长时间运行中保持稳定性

安装前准备

1.依赖下载

[root@localhost ~]# yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
 …………
 Complete! ###安装成功

2、创建用户和组:

[root@localhost ~]# useradd -M -s /sbin/nologin nginx

下载nginx源码包

https://nginx.org/en/download.html ##nginx下载官网
选择要下载的版本点击下载(示例:下载1.12版本)
在这里插入图片描述
上传到虚拟机

编译安装

[root@localhost ~]# tar zxf nginx-1.12.2.tar.gz -C /usr/src/  ##安装到指定目录下
[root@localhost ~]# ls /usr/src/
debug  kernels  nginx-1.12.2
[root@localhost ~]# cd /usr/src/nginx-1.12.2/
[root@localhost ~]#./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module && make && make install
[root@localhost nginx-1.12.2]# echo $?
0  ##可以查看返回值确认安装是否正确

服务优化

[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost nginx-1.12.2]# ng    ##nginx命令可以快捷使用
ngettext  nginx  

控制命令

nginx -t 检测配置文件:ok successful
nginx 开启
nginx -s stop 停止
nginx -s reload 重新加载
nginx -s quit 退出

编辑网站首页

[root@localhost nginx-1.12.2]# vim /usr/local/nginx/html/index.html 
可以自己编辑内容,这里就不做修改

访问验证

[root@localhost nginx-1.12.2]# nginx    ##启动服务
[root@localhost nginx-1.12.2]# ss -tnl  ##查看端口
State       Recv-Q Send-Q                          Local Address:Port                                         Peer Address:Port              
LISTEN      0      128                                         *:80                                                      *:*                  
LISTEN      0      128                                         *:22                                                      *:*                  
LISTEN      0      100                                 127.0.0.1:25                                                      *:*                  
LISTEN      0      128                                        :::22                                                     :::*                  
LISTEN      0      100                                       ::1:25                                                     :::*  

http://192.168.10.112
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值