M-63.第四周作业

1、自建yum仓库,分别为网络源和本地源

CentOS 本地光盘源配置

cd /etc/yum.repos.d/

mkdir back-repo

mv *.repo back-repo

#rm -rf C*

mount /dev/cdrom /mnt

ls /mnt

vim /etc/fstab 永久性挂载配置

#永久挂载

/dev/cdrom    /mnt    iso9660  defaults  0 0

#mount /dev/cdrom /mnt

vim CentOS-local.repo

[bace-local]

name=CentOS-local

baseurl=file:///mnt

enabled=1

gpgcheck=1

gpgkey=file:///mnt/RPM-GPG-CentOS-7

yum clean all

yum makecache

yum repolist

ubuntu光盘源搭建

#老提示缺少文件,待后面处理

apt install dpkg-dev -y

#apt-get install apt-mirror

#vim /etc/apt/sources.list

mount /dev/cdrom /mnt

cp  /etc/apt/sources.list  /etc/apt/sources.list.bak

vim /etc/apt/sources.list

deb  file:////mnt xenial   main  restricted

cd repository

apt-ftparchive packages . > Packages

apt-ftparchive release . > Release

gpg --clearsign -o InRelease Release # 生成签名

#签名配置

gpg --gen-key 


apt-get  update  

#此方法配置时会报错

网络源配置

或 wget 换成 curl

centos 6

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo

centos 7

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

CentOS 8

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

yum clean all

yum makecache

yum repolist

手动配置网络源

cp /etc/yum.repos.d/CentOS-Base.repo CentOS-Base.repo.bak

vim /etc/yum.repos.d/CentOS-Base.repo

#

[base]

name=CentOS-$releasever - Base - mirrors.aliyun.com

failovermethod=priority

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

[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

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras - mirrors.aliyun.com

failovermethod=priority

baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/

        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/

        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#

yum clean all

yum makecache

yum repolist



ubuntu

grep -v '^#' /etc/apt/sources.list

#cp  /etc/apt/sources.list  /etc/apt/sources.list.bak

sed -i.bak /xxx.xxx.ubuntu.com/mirrors.aliyun.com/g /etc/apt/sources.list

sed -ri.bak 's#(.*//).*\.ubuntu\.com#\1mirrors.aliyun.com#g /etc/apt/sources.list

sudo apt-get update  #更新安装包列表

局域网网络源搭建

#server01

#

yum install -y httpd

firewall-cmd --add-service=http

mkdir /apps/httpd/htdocs/westos #使用的编译安装

mount /dev/cdrom /apps/httpd/htdocs/westos

vim /etc/fstab

/dev/cdrom    /apps/httpd/htdocs/westos  iso9660  defaults  0 0

apachectl  #启动网站

#server02

#

cp /etc/yum.repos.d/CentOS-Base.repo CentOS-Base.repo.bak

vim /etc/yum.repos.d/CentOS-Base.repo

#

[base]

name=CentOS-Base

baseurl=http://10.0.0.151/westos/

gpgcheck=1

gpgkey=http://10.0.0.151/westos/RPM-GPG-KEY-CentOS-7

2、编译安装http2.4,实现可以正常访问,并将编译步骤和结果提交。

yum info httpd  #查看 httpd 信息

yum -y install wget #确保能够 wget 功能

mkdir /data/httpd   #创建下载目录

#wget -P /data/httpd https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz

wget -P /data/httpd https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz --no-check-certificate #下载文件

cd /data/httpd/ #进入目录

tar xf httpd-2.4.52.tar.gz #解压

cd httpd-2.4.52  #进入解压目录

[root@localhost httpd]# ls  

httpd-2.4.52  httpd-2.4.52.tar.gz

[root@localhost httpd]# cd httpd-2.4.52

[root@localhost httpd-2.4.52]# ls

ABOUT_APACHE    BuildAll.dsp    configure    httpd.spec      libhttpd.mak  os                srclib

acinclude.m4    BuildBin.dsp    configure.in  include        LICENSE        README            support

Apache-apr2.dsw  buildconf        docs          INSTALL        Makefile.in    README.CHANGES    test

Apache.dsw      CHANGES          emacs-style  InstallBin.dsp  Makefile.win  README.cmake      VERSIONING

apache_probes.d  changes-entries  httpd.dep    LAYOUT          modules        README.platforms

ap.d            CMakeLists.txt  httpd.dsp    libhttpd.dep    NOTICE        ROADMAP

build            config.layout    httpd.mak    libhttpd.dsp    NWGNUmakefile  server

cat INSTALL  #查看安装方法

    #安装过程

    $ ./configure --prefix=PREFIX 

    $ make

    $ make install

    $ PREFIX/bin/apachectl start  #启动

#查看configure支持选项及功能

./configure --help

#指定配置文件安装目录并启用ssl

./configure --prefix=/apps/httpd \

--sysconfdir=/etc/httpd/ \

--enable-ssl   

#./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

[root@localhost httpd-2.4.52]# ./configure --prefix=/apps/httpd \

> --sysconfdir=/etc/httpd/ \

> --enable-ssl

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking target system type... x86_64-pc-linux-gnu

configure:

configure: Configuring Apache Portable Runtime library...

configure:

checking for APR... no

configure: error: APR not found.  Please read the documentation.

yum install -y apr-devel

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

configure: Configuring Apache Portable Runtime Utility library...

configure:

checking for APR-util... no

configure: error: APR-util not found.  Please read the documentatio

yum install -y apr-util-devel

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

checking for APR-util... yes

checking for gcc... gcc

checking whether the C compiler works... no

configure: error: in `/data/httpd/httpd-2.4.52':

configure: error: C compiler cannot create executables

See `config.log' for more details

cat config.log

.........

configure:5459: checking for gcc

configure:5491: result: gcc

configure:5844: checking for C compiler version

configure:5853: gcc --version >&5

./configure: line 5855: gcc: command not found

configure:5864: $? = 127

configure:5853: gcc -v >&5

./configure: line 5855: gcc: command not found

configure:5864: $? = 127

configure:5853: gcc -V >&5

./configure: line 5855: gcc: command not found

configure:5864: $? = 127

configure:5853: gcc -qversion >&5

./configure: line 5855: gcc: command not found

configure:5864: $? = 127

configure:5853: gcc -version >&5

./configure: line 5855: gcc: command not found

........

yum install -y gcc

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

......

checking for pcre-config... false

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

yum install -y pcre-devel

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

..........

configure: WARNING: OpenSSL version is too old

no

checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures

yum install -y openssl-devel

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

configure: summary of build options:

    Server Version: 2.4.52

    Install prefix: /apps/httpd

    C compiler:    gcc -std=gnu11

    CFLAGS:          -pthread 

    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE 

    LDFLAGS:         

    LIBS:           

    C preprocessor: gcc -E

[root@localhost httpd-2.4.52]# echo $?

0

#查看CPU核数

lscpu |grep CPU

CPU op-mode(s):        32-bit, 64-bit

CPU(s):                2

make -j 2

make install

ls /apps/httpd

ls /etc/httpd

[root@localhost httpd-2.4.52]# curl 127.0.0.1

curl: (7) Failed connect to 127.0.0.1:80; Connection refused

# PREFIX/bin/apachectl start  #启动

/apps/httpd/bin/apachectl start

curl 127.0.0.1

<html><body><h1>It works!</h1></body></html>

/apps/httpd/bin/apachectl stop

#加入到PATH

echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh

. /etc/profile.d/httpd.sh

echo $PATH #确认变量加入到PATH

apachectl

apachectl stop

重新整理后

yum install -y wget apr-devel apr-util-devel gcc pcre-devel openssl-devel

wget -P /data/httpd https://dlcdn.apache.org//httpd/httpd-2.4.52.tar.gz --no-check-certificate

./configure --prefix=/apps/httpd --sysconfdir=/etc/httpd/ --enable-ssl

make -j 2

make install

echo 'PATH=/apps/httpd/bin:$PATH' > /etc/profile.d/httpd.sh

. /etc/profile.d/httpd.sh

apachectl

apachectl stop


3、利用sed 取出ifconfig命令中本机的IPv4地址

#ip a |sed -n '/\/24/p' |sed 's/inet.//g' |sed 's/brd.*$//g'

yum install net-tools -y

ifconfig eth0 |sed -n '/mask/p'|sed 's/.inet//g'|sed -s 's/ //g'|sed 's/netmask.*$//g'

ifconfig eth0 |sed -n '/mask/p'|sed 's/ /\n/g' |sed '/^$/d'|sed -n '2p'

[root@localhost ~]# ifconfig eth0 |sed -n '/mask/p'|sed 's/.inet//g'|sed -s 's/ //g'|sed 's/netmask.*$//g' 

10.0.0.151 

4、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符

cat /etc/fstab|sed '/^#/d'|sed '/^$/d' //

5、处理/etc/fstab路径,使用sed命令取出其目录名和基名

ls /etc/fstab |sed 's#/#\n#g'|sed -n '$p'

#或

ls /etc/fstab |sed 's/^.*\///g'

#basename /etc/fstab

6、列出ubuntu软件管理工具apt的一些用法(自由总结)

#安装包

sudo apt install [package name1] [package-name2] [package-name3] -y

#卸载包

sudo apt remove [package name]

#清除安装包残余

sudo apt --purge remove [package-name]

#删除孤立安装包

sudo apt autoremove

#更新APT储存库

sudo apt update

#升级系统软件包(非关键软件包)

sudo apt upgrade

#升级系统软件包 (完整的)

sudo apt full-upgrade

#搜索包

sudo apt search [keyword]

附录YUM用法

1. 列出所有可更新的软件清单命令:yum check-update

2. 更新所有软件命令:yum update

3. 仅安装指定的软件命令:yum install <package_name>

4. 仅更新指定的软件命令:yum update <package_name>

5. 列出所有可安裝的软件清单命令:yum list

6. 删除软件包命令:yum remove <package_name>

7. 查找软件包命令:yum search <keyword>

8. 清除缓存命令:

yum clean packages: 清除缓存目录下的软件包

yum clean headers: 清除缓存目录下的 headers

yum clean oldheaders: 清除缓存目录下旧的 headers

yum clean, yum clean all (= yum clean packages; yum clean oldheaders) :清除缓存目录下的软件包及旧的 headers

yum install pam-devel 安装

yum remove pam-devel 移除

yum list pam*  列出

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,490评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,581评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,830评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,957评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,974评论 6 393
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,754评论 1 307
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,464评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,357评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,847评论 1 317
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,995评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,137评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,819评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,482评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,023评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,149评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,409评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,086评论 2 355

推荐阅读更多精彩内容