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 ~~

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