一、自建yum倉庫,分別爲網絡源和本地源php
(1)啓動服務html
查看是否安裝了autofs包linux
[22:09:27 root@CentOS7 /run/media/centos7.6/CentOS 7 x86_64]#rpm -q autofs
autofs-5.0.7-99.el7.x86_64apache
包中有一個autofs.servic服務vim
[21:56:41 root@CentOS7 ~]#rpm -ql autofs |grep .*service
/usr/lib/systemd/system/autofs.serviccentos
啓動autofs.servic服務,會多一個/misc文件夾bash
[21:56:55 root@CentOS7 ~]#systemctl start autofs (該方法啓動,從新啓動後/misc沒法查看到,因此需使用下面該命令網絡
[21:59:42 root@CentOS7 /misc]#systemctl enable autofsapp
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.dom
[22:14:47 root@CentOS7 /]#ls
bin data etc lib media mnt opt root sbin sys usr
boot dev home lib64 misc net proc run srv tmp var
(2)查看misc目錄
[22:25:32 root@CentOS7 /]#cd /misc
[22:25:36 root@CentOS7 /misc]#ls
上面直接查看/misc目錄中沒有任何內容,先進入/misc/cd中再次查看會多一個cd目錄
[22:25:37 root@CentOS7 /misc]#cd /misc/cd
[22:26:37 root@CentOS7 /misc/cd]#cd /misc
[22:26:56 root@CentOS7 /misc]#ls
cd
此時cd目錄中的內容
[22:28:18 root@CentOS7 /misc]#ls cd/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7 EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
此時光盤是掛接在:/misc/cd
[22:28:25 root@CentOS7 /misc]#df /dev/sr0
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sr0 4480476 4480476 0 100% /misc/cd
(3)以 /misc/cd 做爲yum的路徑
查看yum的配置文件
[22:41:39 root@CentOS7 /etc/yum.repos.d]#cat /etc/yum.conf
[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release [22:42:24 root@CentOS7 /etc/yum.repos.d]#ls /etc/yum.repos.d/ CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
原有的repo作一個備份
[22:50:08 root@CentOS7 /etc/yum.repos.d]#mkdir bak;mv *.repo bak/
本身建一個repo文件
[22:50:59 root@CentOS7 /etc/yum.repos.d]#vim base.repo
[base]
name = tao base
baseurl = file:///misc/cd #(本地源,以光盤做爲yum源)
gpgcheck=0配置一個epel源
[epel]
name= aliyun epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/ #(網絡源)
gpgcheck=0
enabled=1
[23:02:49 root@CentOS7 /etc/yum.repos.d]#cat base.repo
[base] name = tao base baseurl = file:///misc/cd gpgcheck=0 [epel] name= aliyun epel baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/ gpgcheck=0 enabled=1
(4)查看
[23:04:16 root@CentOS7 /etc/yum.repos.d]#yum repolist
Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile base | 3.6 kB 00:00:00 Not using downloaded base/repomd.xml because it is older than what we have: Current : Wed Apr 22 07:37:50 2020 Downloaded: Mon Nov 26 07:53:36 2018 epel | 4.7 kB 00:00:00 (1/3): epel/7/x86_64/group_gz | 95 kB 00:00:00 (2/3): epel/7/x86_64/updateinfo | 1.0 MB 00:00:01 (3/3): epel/7/x86_64/primary_db | 6.8 MB 00:00:02 repo id repo name status base tao base 10,070 epel/7/x86_64 aliyun epel 13,382 repolist: 23,452
二、編譯安裝http2.4,實現能夠正常訪問,並將編譯步驟和結果提交。
下載及解壓:
[22:24:36 root@CentOS7 /data]#wget http://archive.apache.org/dist/httpd/httpd-2.4.25.tar.gz
[23:28:15 root@CentOS7 /data]#tar xvf httpd-2.4.25.tar.gz
查看解壓文件:
[23:33:06 root@CentOS7 /data/httpd-2.4.25]#ls
ABOUT_APACHE ap.d CHANGES docs httpd.spec libhttpd.dep Makefile.win README srclib acinclude.m4 build CMakeLists.txt emacs-style include libhttpd.dsp modules README.cmake support Apache-apr2.dsw BuildAll.dsp config.layout httpd.dep INSTALL libhttpd.mak NOTICE README.platforms test Apache.dsw BuildBin.dsp configure httpd.dsp InstallBin.dsp LICENSE NWGNUmakefile ROADMAP VERSIONING apache_probes.d buildconf configure.in httpd.mak LAYOUT Makefile.in os server
能夠經過README ;INSTALL查看安裝方法
configure的安裝;參考Makefile.in 用腳本configure 生成Makefile文件
configure 安裝注意 :
1.安裝路徑要指定
2.哪些特性須要啓用,哪些特性不須要啓用
安裝步驟:
1./configure --prefix=PREFIX
2.make
3.make install
4.PREFIX/bin/apachectl start
執行安裝操做
1.[23:59:19 root@CentOS7 /data/httpd-2.4.25]#./configure \
--prefix=/apps/httpd24 \
--sysconfdir=/etc/httpdt \
--enable-ssl \
--enable-so
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-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
執行上面命令,出現報錯,解決該錯誤方法:通常安裝:名字+」-devel」的包便可,對於上面的報錯,即安裝:APR-devel包
會涉及安裝的包以下所示:
yum install gcc
yum install apr-devel -y
yum install apr-util-devel -y
yum install pcre-devel -y
yum install openssl-devel -y
安裝完全部的包後,執行第一步的命令
2.make -j 4
3.make install
4.測試是否安裝成功
1)可在安裝目錄中直接運行aparchctl start
[13:05:28 root@CentOS7 ~]#. /apps/httpd24/bin/apachectl start
2)或者寫入變量當中(這種方法,當從新電腦啓動後,服務是沒法自動啓動的)
[09:58:12 root@CentOS7 /etc/profile.d]#vim env.sh
[09:59:05 root@CentOS7 /etc/profile.d]#. env.sh
[09:59:16 root@CentOS7 /etc/profile.d]#echo $PATH
/apps/httpd24/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[09:59:22 root@CentOS7 /etc/profile.d]#apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using CentOS7.6.localdomain. Set the 'ServerName' directive globally to suppress this message
讓apachectl服務開機時自動啓動
(1)[13:17:50 root@CentOS7 ~]#vim /etc/rc.d/rc.local
在rc.local中加入如下內容(以下圖所示,前面的路徑是在--prefix=/apps/httpd24中設置的路徑)
/apps/httpd24/bin/apachectl start
(2)還需加上執行權限
chmod +x /etc/rc.d/rc.local
在網頁中輸入ip地址,如能顯示,則表示安裝成功
能夠在index.html中修改顯示內容:
三、建立一個2G的文件系統,塊大小爲2048byte,預留1%可用空間,文件系統 ext4,卷標爲TEST,要求此分區開機後自動掛載至/test目錄,且默認有acl掛載選項
1).查看硬盤
[00:00:45 root@CentOS7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
sr0 11:0 1 4.3G 0
此處以sdb硬盤進行實驗
2).對sdb分一個2G的分區
[00:01:51 root@CentOS7 ~]#fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xc849f931.
Command (m for help): n ( n:建立一個分區)
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G
Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): w ( w:保存退出)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[00:08:24 root@CentOS7 ~]#lsblk /dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 20G 0 disk
└─sdb1 8:17 0 2G 0 part
3).建立文件系統
[10:24:22 root@CentOS7 ~]#mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdb1
[10:26:25 root@CentOS7 ~]#blkid /dev/sdb1
/dev/sdb1: LABEL="TEST" UUID="9ef4eb89-c0ae-443f-bb53-2bbaa169ab47" TYPE="ext4"
配置文件/etc/fstab中加入如下代碼
UUID=9ef4eb89-c0ae-443f-bb53-2bbaa169ab47 /test ext4 acl 0 0
[10:48:07 root@CentOS7 /test]#mkdir /test
[10:48:07 root@CentOS7 /test]#mount –a
查看
[10:50:13 root@CentOS7 /test]#df /dev/sdb1
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb1 1998538 9236 1960140 1% /test
四、建立一個至少有兩個PV組成的大小爲20G的名爲testvg的VG;要求PE大小 爲16MB, 然後在卷組中建立大小爲5G的邏輯卷testlv;掛載至/users目錄
查看磁盤狀況
[20:37:13 root@CentOS7 ~]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 100G 0 part /
├─sda3 8:3 0 50G 0 part /data
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 2G 0 part /test
└─sdb2 8:18 0 18G 0 part
sdc 8:32 0 100G 0 disk
└─sdc1 8:33 0 2G 0 part
sr0 11:0 1 4.3G 0 rom
以sdb2和sdc1做爲pv
1).建立物理卷
建立
[20:44:10 root@CentOS7 ~]#pvcreate /dev/sd{b2,c1}
Physical volume "/dev/sdb2" successfully created.
Physical volume "/dev/sdc1" successfully created.
查看
[20:44:49 root@CentOS7 ~]#pvs
PV VG Fmt Attr PSize PFree
/dev/sdb2 lvm2 --- <18.00g <18.00g
/dev/sdc1 lvm2 --- 2.00g 2.00g
2).建立卷組
建立
[20:51:26 root@CentOS7 ~]#vgcreate testvg /dev/sd{b2,c1} -s 16M
Volume group "testvg" successfully created
查看
3).建立邏輯卷
建立
[20:54:11 root@CentOS7 ~]#lvcreate -n testlv -L 5G testvg
Logical volume "testlv" created.
查看
4.建立文件系統
[21:18:51 root@CentOS7 ~]#mkfs.xfs /dev/testvg/testlv
5掛載
[21:23:02 root@CentOS7 ~]#mkdir /users ;mount /dev/testvg/testlv /usrs/