由于此次咱们实际上有在线安装和离线安装的不一样的需求。
因此咱们同时采用了两种方法来安装nginx。html
安装nginx对应的源 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install nginx
打开网址 http://nginx.org/packages/rhel/7/x86_64/RPMS/ 下载对应的文件 http://nginx.org/packages/rhel/7/x86_64/RPMS/nginx-1.14.0-1.el7_4.ngx.x86_64.rpm 把下载的文件放置到 /opt/soft下面,使用下面命令 rpm -ivh nginx-1.14.0-1.el7_4.ngx.x86_64.rpm 进行安装
yum remove nginx
# 启动nginx service nginx start # 中止nginx service nginx stop # 查看nginx状态 service nginx status # 使用http进行访问 http://ip地址/ # 关闭防火墙 1. firewalld防火墙 查看默认防火墙状态。 (关闭后显示notrunning,开启后显示running) firewall-cmd --state 中止firewall systemctl stop firewalld.service 禁止firewall开机启动 systemctl disable firewalld.service 2. iptables防火墙 若是安装了iptables, 咱们还须要关闭iptables 查看iptables状态 service iptables status 中止iptables service iptables stop 启动的时候关闭iptables chkconfig iptables off # 关闭selinux 永久关闭selinux,须要经过修改配置文件/etc/selinux/config。 vim /etc/selinux/config 修改SELINUX。参数可选(enforcing、permissive、disabled) SELINUX=disabled 须要reboot重启生效。
开放目录权限 vi /etc/nginx/nginx.conf 在配置文件里面加入如下参数 autoindex on; autoindex_exact_size on; autoindex_localtime on; 其中autoindex_exact_size on; 显示出文件的确切大小,单位是bytes。 改成off后,显示出文件的大概大小,单位是kB或者MB或者GB 而autoindex_localtime on; 默认为off,显示的文件时间为GMT时间。 改成on后,显示的文件时间为文件的服务器时间
咱们先规划两个目录。
centos7.5 存放centos7.5的本地文件源。
cm5存放Cloudera Manager 5的源。linux
# 进入nginx主目录 cd /usr/share/nginx/html # 配置centos7.5的文件夹 ln -s /mnt/centos7.5/ ./centos7.5 # 配置cm5的文件夹, cm5的文件默认放在/opt/soft/cm目录下面 ln -s /opt/soft/cm ./cm
# 查看机器名称 hostname # 设置机器名称为dev-repo001 hostnamectl set-hostname dev-repo001 # 设置hosts为本身的ip地址 vi /etc/hosts # 添加本身的ip地址 127.0.0.1 dev-repo001 # 测试 ping dev-repo001
这里定义了两个repo,一个是Centos7.5的repo。
一个是Cloudera Manager的repo。nginx
进入repo文件夹 cd /etc/yum.repos.d/ 修改原来的本地repo [root@dev-basic yum.repos.d]# cat centos7.5-local.repo [cenots7.5-local] name=centos7.5 baseurl=file:///mnt/centos7.5 enabled=1 gpgcheck=0 修改其中的baseurl=file:///mnt/centos7.5 为baseurl=http://dev-repo001/centos7.5 修改后的文件以下 定义repo文件 vi /etc/yum.repos.d/cloudera-cm.repo 加入如下内容 # Packages for Cloudera's Distribution for cm, Version 5, on RedHat or CentOS 7 x86_64 name=Cloudera's Distribution for cm, Version 5 baseurl=http://dev-repo001/cm gpgkey = http://dev-repo001/cm/RPM-GPG-KEY-cloudera gpgcheck = 1