yum源及rpm、源码包
配置yum软件仓库
# cd /etc/yum.repos.d # ls # mkdir bak # mv Cent* /bak 将原有的配置文件移动到备份文件夹中。 # vim CentOS7.repo 新建文件必须以 .repo为后缀,名称可以随意取 [rhel-media] #yum软件仓库的唯一标识符,避免与其他软件仓库冲突 name=linux-yhy #yum软件仓库的名称描述,易于识别仓库的用处 baseurl=file:///mnt/cdrom #提供的方式为本地文件 enabled=1 #设置此源是否可用,1为可用,0为禁用 gpgcheck=0 #设置此源是否为检验文件,1为校验,0为不校验 # mount /dev/cdrom /mnt # yum list #查看当前的yum源 # yum install -y httpd # yum remove -y httpd
# systemctl start httpd
# systemctl stop firewalld
# systemctl disable firewalld
# vim /root/.bashrc mount /dev/cdrom /mnt/cdrom
yum参数
# yum reinstall -y httpd 重新安装 # yum -y update httpd 升级安装(升级) # yum -y update 升级系统 # yum list httpd 查询 # yum repolist //查yum源信息 # yum search mysql //搜索到系统已经安装和yum源里没有安装的得软件信息 # yum deplist //查看软件依赖关系 # yum provides vim ##查看文件属于哪个软件 # yum list //查看已安装和没有安装的软件 # yum -y remove httpd 卸载软件包 # yum -y erase httpd 卸载 # yum clean all //清理Yum缓存 # yum makecache //创建新Yum缓存软件包信息(提高搜索/安装软件的速度)
阿里巴巴开源镜像站:https://developer.aliyun.com/mirror/
# cd /etc/yum.repos.d/ # mkdir bak # mv Cent* /bak # wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo //curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo # vim CentOS-Base.repo
epel镜像(扩展包)
EPEL (Extra Packages for Enterprise Linux), 是由 Fedora Special Interest Group 维护的 Enterprise Linux(RHEL、CentOS)中经常用到的包。
yum install -y epel-release
# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo # yum makecache # yum repolist 查看源 # yum -y install httpd # systemctl start httpd # systemctl stop firewalld
RPM
# cd /mnt/cdrom/Packages # rpm -ivh wget* //安装 # rpm -ivh xxx --nodeps //忽略依赖关系 # rpm -q wget //-a 全部 # rpm -evh wget-1.14(写全称) //卸载
# rpm -ql 程序名 //查看软件安装路径(文件列表) # rpm -qa # rpm -qi //查看包软件信息 # rpm -qf /etc/passwd //查看文件由哪些软件产生
# rpm -qc xxx # rpm -e ntfs-3g //卸载 # --force 强制安装 # --nodeps 卸载时,不检测依赖关系
源码包:
source code 需要经过GCC,C++编译环境编译才能运行
可以设定个人设置,开关功能
软件包示例:nginx-1.8.1.tar.gz
官方网站:https://tengine.taobao.org/ (tengine从nginx基础上改)
# cd /root/下载/ # wget https://tengine.taobao.org/download/tengine-2.3.2.tar.gz # yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel # useradd www # tar xf tengine-2.3.2.tar.gz # cd tengine-2.3.2/ # ./configure --user=www --group=www --prefix=/usr/local/nginx # make # make install //有httpd服务先停 systemctl stop httpd # systemctl stop firewalld # /usr/local/nginx/sbin/nginx
127.0.0.1测试
win上下载或
wget https://tengine.taobao.org/download/tengine-2.3.2.tar.gz
rz(上传)
# yum provides rz lrzsz-0.12.20-36.el7.x86_64 # yum install -y lrzsz-0.12.20-36.el7.x86_64 # rz //选择上传的文件 # rm -rf /tmp/* # mv tengine-2.3.2.tar.gz /tmp # yum clean all # yum makecache # yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel # # useradd www # tar xvf tengine-2.2.0.tar.gz # cd tengine-2.2.0 # ./configure --user=www --group=www --prefix=/usr/local/nginx --with=pcre # make # make install # lsof -i:80 # /usr/local/nginx/sbin/nginx //启动 # lsof -i:80
lsof命令用于查看你进程开打的文件,打开文件的进程,进程打开的端口(TCP、UDP)。找回/恢复删除的文件。是十分方便的系统监视工具,因为lsof命令需要访问核心内存和各种文件,所以需要root用户执行。
源码包安装错误解析
模拟问题一
# /usr/local/nginx/sbin/nginx -s stop # rm -rf /usr/local/nginx # lsfo -i:80 # kill -9 id号 (关不完) # killall nginx (没有killall) # yum provides killall psmisc-22.20-16.el7.x86_64 # yum install -y psmisc-22.20-16.el7.x86_64 # killall nginx # lsof -i:80
模拟问题二
# cd /tmp/ # rm -rf tengine-2.2.0 # id www # userdel -r www # tar xvf tengine-2.2.0.tar.gz # cd tengine-2.2.0 # ./configure --user=www --group=www --prefix=/usr/local/nginx --with=pcre # make # make install # /usr/local/nginx/sbin/nginx (提示缺少用户) # useradd www # /usr/local/nginx/sbin/nginx nginx: [emerg] getwnam("www") failed # chattr -i /etc/passwd # useradd www # /usr/local/nginx/sbin/nginx
chattr:
+<属性>:开启文件或目录的该项属性; -<属性>:关闭文件或目录的该项属性;
配置若有遗漏或错误,请评论留言。