zoukankan      html  css  js  c++  java
  • linux普通用户使用yum安装nginx,并使用nginx

    背景

    探索linux普通用户使用yum安装nginx

    环境
    1. mac 上安装 virtualbox
    2. virtualbox 上安装 centos7
    3. centos7 安装 nginx,并起nginx服务
    4. mac可以ping通virtualbox中的centos7服务器

    5. 网络连通配置参考:https://www.cnblogs.com/syw-home/p/12716352.html

    1. mac本地网络:192.168.0.101
    2. 虚拟机中网络:192.168.0.105

    yum换成国内源,例如清华源

    https://mirrors.tuna.tsinghua.edu.cn/help/centos/

    普通用户使用yum需要使用sudo yum install xxx

    需要在root用户下在vi /etc/sudoers, 写入 user ALL=(ALL) ALL 如下图

     sudo yum install nginx 遇到:没有可用软件包 nginx

    原因是nginx位于第三方的yum源里面,而不在centos官方yum源里面

    解决办法,安装epel

    sudo yum install epel-release

    sudo yum update

    再次执行sudo yum install nginx 可以安装了

    如上安装后,nginx被安装到哪里了???

    安装到了root用户下

    如何玩nginx

    1. 启动nginx
      1. 开启:/usr/sbin/nginx -c /etc/nginx
      2. 重启:/sur/sbin/nginx -s reload
    2. 修改配置nginx
      1. vi /etc/nginx/nginx.conf
      2.  或者将自己的index.html 放入到 /usr/share/nginx/html

    验证服务是否可用

    1. 本地先验证
      1.  curl localhost
    2. mac上的浏览器输入虚拟机起的centos ip:http://192.168.0.105/
      1. 开始不通,原因是防火墙没关
        1. systemctl status firewalld # 查看防火墙状态
        2. systemctl stop firewalld # 临时关闭
        3. systemctl disable firewalld # 永久关闭
      2. 在mac上的访问成功!!!
  • 相关阅读:
    POJ 1936 All in All
    POJ 2305 Basic remains
    POJ 2081 Recaman's Sequence
    MFC MDI 窗口函数执行顺序
    decompose
    不新建一个文档
    code mistake
    ...
    paper
    stereo
  • 原文地址:https://www.cnblogs.com/syw-home/p/12724143.html
Copyright © 2011-2022 走看看