yum安装Nginx1.18

 

本次实验使用系统:

[root@test-04 ~]# lsb_release -a
LSB Version:  :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:  CentOS Linux release 7.7.1908 (Core)
Release:  7.7.1908
Codename: Core
  1. 关闭selinux和防火墙

[root@mysql-server-01 ~]# getenforce
Enforcing
[root@mysql-server-01 ~]# setenforce 0
[root@mysql-server-01 ~]# getenforce
Permissive
[root@mysql-server-01 ~]# firewall-cmd --state
running
[root@mysql-server-01 ~]# systemctl stop firewalld.service
[root@mysql-server-01 ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@mysql-server-01 ~]# firewall-cmd --state
not running

更新系统时间

[root@mysql-server-01 ~]# yum -y install ntp ntpdate
[root@mysql-server-01 ~]# ntpdate 0.asia.pool.ntp.org
25 Apr 16:17:54 ntpdate[2056]: step time server 203.107.6.88 offset 3699663.834363 sec
[root@mysql-server-01 ~]# hwclock --systohc
[root@mysql-server-01 ~]# date
2020年 04月 25日 星期六 16:18:07 CST

开始安装

  1. 准备yum

yum -y install yum-utils
  1. 配置nginx repos

vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
​
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
  1. 完成nginx-mainline配置

yum-config-manager --enable nginx-mainline
  1. 安装Nginx

yum install nginx
  1. 相关目录 主要目录

    nginx 日志文件 /var/log/nginx
    nginx配置文件目录 /etc/nginx
    nginx 可执行文件 /usr/sbin/nginx
    nginx环境配置 /etc/sysconfig/nginx
    nginx默认站点目录  /usr/share/nginx/html

    其他目录

    /etc/logrotate.d/nginx
    /var/cache/nginx
    /usr/lib64/nginx
    /usr/libexec/initscripts/legacy-actions/nginx
    1. 常用命令 #测试配置文件正确性

    nginx -t

    #信号命令

    nginx -s [signal]
    nginx -s reload 刷新配置
    nginx -s fast 快速stop
    nginx -s graceful 优雅stop

    #启停服务

    service nginx status | stop | start
    1. 设置开机启动

    systemctl enable nginx
    1. 查看版本

    nginx -v
    nginx version: nginx/1.18.0

    Over ~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章