zoukankan      html  css  js  c++  java
  • centos7 nginx安装

    阿里云上买了个域名,准备玩一下。安装nginx

    官网地址:

    http://nginx.org/

    官方文档,一步步来。

    添加nginx源:

    [root@xyjk1002 ~]# cat /etc/yum.repos.d/nginx.repo 
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=0
    enabled=1

    更新缓存

    [root@xyjk1002 ~]# yum clean all & yum makecache

    安装,好小

    [root@xyjk1002 yum.repos.d]# yum install nginx
    Loaded plugins: langpacks
    Resolving Dependencies
    --> Running transaction check
    ---> Package nginx.x86_64 1:1.8.1-1.el7.ngx will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==============================================================================================================================================================================================================================
     Package                                           Arch                                               Version                                                         Repository                                         Size
    ==============================================================================================================================================================================================================================
    Installing:
     nginx                                             x86_64                                             1:1.8.1-1.el7.ngx                                               nginx                                             372 k
    
    Transaction Summary
    ==============================================================================================================================================================================================================================
    Install  1 Package
    
    Total download size: 372 k
    Installed size: 897 k
    Is this ok [y/d/N]: 

    开启服务:

    [root@xyjk1002 ~]# systemctl start nginx.service

    查看一下我们的公网ip

    [root@xyjk1002 ~]# ip addr show eth1 | grep inet | awk '{ print $2; }' | sed 's//.*$//'

    在浏览器中输入ip

    出现页面,则说明成功

    nginx默认配置文件:

    [root@xyjk1002 ~]# cat /etc/nginx/conf.d/default.conf 
    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;
        #access_log  /var/log/nginx/log/host.access.log  main;

        location / {
            root   /usr/share/nginx/html;//网站根目录位置
            index  index.html index.htm;//网站首页默认页面名称
        }


    最后添加防火墙规则:

    [root@xyjk1002 ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
    success
    [root@xyjk1002 ~]# firewall-cmd --reload 
    success
    [root@xyjk1002 ~]# firewall-cmd --list-all
    public (default)
      interfaces: 
      sources: 
      services: dhcpv6-client ssh
      ports: 80/tcp 22/tcp
      masquerade: no
      forward-ports: 
      icmp-blocks: 
      rich rules: 
        
  • 相关阅读:
    TP5报如下的错误 Indirect modification of overloaded element of thinkpaginatorCollection has no effect【转】
    PHPnumber_format()函数的使用
    蓝桥杯-PREV28-地宫取宝
    HihoCode-1053-居民迁移
    HihoCode-1323-回文字符串
    蓝桥杯-PREV3-带分数
    HDU-6312-Game
    HDU-6438-Buy and Resell
    CF-1117C-Magic Ship
    HDU-2802-F(N)
  • 原文地址:https://www.cnblogs.com/XYJK1002/p/5381113.html
Copyright © 2011-2022 走看看