一、程序软件与rqm
rpm命令:rpm [OPTIONS] [PACKAGE_FILE]# i表示安装 v显示详细过程 h以进度条显示,每个#表示2%进度安装软件的命令格式 rpm -ivh filename.rpm升级软件的命令格式 rpm -Uvh filename.rpm卸载软件的命令格式 rpm -e filename.rpm查询软件描述信息的命令格式 rpm -qpi filename.rpm列出软件文件信息的命令格式 rpm -qpl filename.rpm查询文件属于哪个 RPM 的命令格式 rpm -qf filename
二、yum工具
yum主要是解决用户的软件安装依赖的关系
yum客户端 # /etc/yum.conf/etc/yum.conf #为所有仓库提供公共配置[root@chaogelinux yum.repos.d]# cat /etc/yum.conf[main]cachedir=/var/cache/yum/$basearch/$releaseverkeepcache=0 #本地缓存是否保留,0否,1是debuglevel=2 #调试日志级别logfile=/var/log/yum.log #日志路径exactarch=1 #精确系统平台版本匹配obsoletes=1gpgcheck=1 #检查软件包的合法性plugins=1installonly_limit=5 #同时安装几个工具包bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yumdistroverpkg=centos-release# This is the default, if you make this bigger yum won't see if the metadata# is newer on the remote and so you'll "gain" the bandwidth of not having to# download the new metadata and "pay" for it by yum not having correct# information.# It is esp. important, to have correct metadata, for distributions like# Fedora which don't keep old packages around. If you don't like this checking# interupting your command line usage, it's much better to have something# manually check the metadata once an hour (yum-updatesd will do this).# metadata_expire=90m#请放置你的仓库在这里,并且命名为*.repo类型# PUT YOUR REPOS HERE OR IN separate files named file.repo# in /etc/yum.repos.d
标准的repo文件格式:
/etc/yum.repos.d/*.repo #提供仓库的地址文件
CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com #仓库文件的说明
failovermethod=priority #存在多个url的时候,按顺序来连接,如果是roundrobin,意为随机挑选
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ #指定仓库的网站地址
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1 #是否检测秘钥
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #公钥文件存放路径
#released updates 指定rpm包需要升级的地址,此处可以去网页上寻找对应的包
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
epel.conf
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyun.com/epel/7/$basearch
failovermethod=priority
enabled=1 #是否启用此仓库
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
简单定义一个
[base]
name=Chaoge repo
baseurl=http://chaoge.com/centos/7/os/x86_64/
gpgcheck=0
[epel]
name=Chaoge epel repo
baseurl=http://chaoge.com/epel/7/os/x86_64/
gpgcheck=0
yum install nginx #安装软件
yum remove nginx #卸载软件
yum update nginx #更新软件,如果不加软件名表示更新全部
[root@ylinux ~]# yum repolist all #显示当前的仓库有哪些
[root@ylinux ~]# yum list nginx #显示一个软件的可安装列表
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
nginx.x86_64 1:1.16.1-3.el7
三、源代码编译安装
开发工具:gcc make等
开发组件:
yum groupinstall "Development Tools"
yum groupinstall "Server Platform Development"
1.准备编译环境
yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl openssl-devel -y
2.获取nginx源代码
wget -c https://nginx.org/download/nginx-1.12.0.tar.gz
3.解压缩nginx源代码
tar -zxvf nginx-1.12.0.tar.gz
4.进入源码目录
cd nginx-1.12.0
5.开始编译三部曲
./configure --prefix=/opt/nginx112/ --with-http_ssl_module --with-http_stub_status_module
6.执行make指令,调用gcc等编译工具
make
7.开始安装
make install
8.安装后启动nginx软件,找到二进制程序,以绝对路径执行
/opt/ngx112/sbin/nginx
9.检查环境变量,需要手动配置nginx的PATH路径,否则必须绝对路径才能找到
编辑文件/etc/profile.d/nginx.sh
写入export PATH=/opt/ngx112/sbin:$PATH
10.退出回话,重新登录机器
logout
11.检查环境变量
[root@chaogelinux ngx112]# cat /etc/profile.d/nginx.sh
export PATH=/opt/ngx112/sbin:$PATH
12.启动nginx,可以访问页面
