Configure network YUM source and third-party YUM source and compile and install Apache
System hardware and software environment platform:
VMware Workstation Pro 12.5.5 build-5234757
CentOS Linux release 7.3.1611
Kernel version: 3.10.0-514.el7.x86_64
Test time: June 13, 2017
Experiment 1: Implementing Network YUM Source
1. Prepare relevant system CD-ROM and build network service ftp or http
[Execution of orders]#ls /mnt [Execution of orders]#mount | grep "/dev/sr0" [Execution of orders]#mount /dev/sr0 /mnt mount: /dev/sr0 is write-protected, mounting read-only [Execution of orders]#cd /mnt/Packages/ [Execution of orders]#rpm -ivh vsftpd-3.0.2-21.el7.x86_64.rpm warning: vsftpd-3.0.2-21.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:vsftpd-3.0.2-21.el7 ################################# [100%] [Execution of orders]#netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN [Execution of orders]#System CTL start vsftpd // start service
#########################
vsftpd service settings
centos6 version path / etc/rc.d/init.d/vsftpd
/ etc/rc.d/init.d/vsftpd start//start service
service vsftpd start//ibid.
chkconfig vsftpd on // Set up boot-up automatic start-up service
centos7 version path / usr / lib / system D / system / vsftpd. service
System CTL start vsftpd // start service
System CTL enable vsftpd // Set up boot-up automatic start-up service
Setup of iptables firewall
centos6
service iptables stop // disabled
chkconfig iptables off // disabled next boot
centos7
System CTL stop firewalld. service // disabled
System CTL disable firewalld.service//Disabled next boot
############################
[Execution of orders]#netstat -ntl Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp6 0 0 :::111 :::* LISTEN tcp6 0 0 :::21 :::* LISTEN //Display the port number of FTP to indicate that the service started successfully tcp6 0 0 :::22 :::* LISTEN tcp6 0 0 ::1:631 :::* LISTEN tcp6 0 0 ::1:25 :::* LISTEN [Execution of orders]#iptables -vnL Chain INPUT (policy ACCEPT 2092 packets, 171K bytes) pkts bytes target prot opt in out source destination 0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53 0 0 ACCEPT udp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 0 0 ACCEPT tcp -- virbr0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67 Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination 0 0 ACCEPT all -- * virbr0 0.0.0.0/0 192.168.122.0/24 ctstate RELATED,ESTABLISHED 0 0 ACCEPT all -- virbr0 * 192.168.122.0/24 0.0.0.0/0 0 0 ACCEPT all -- virbr0 virbr0 0.0.0.0/0 0.0.0.0/0 0 0 REJECT all -- * virbr0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable 0 0 REJECT all -- virbr0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable Chain OUTPUT (policy ACCEPT 1714 packets, 189K bytes) pkts bytes target prot opt in out source destination 0 0 ACCEPT udp -- * virbr0 0.0.0.0/0 0.0.0.0/0 udp dpt:68 [Execution of orders]#Iptables-F // / Recommendation to clear the firewall to avoid affecting the experimental results [Execution of orders]#iptables -vnL Chain INPUT (policy ACCEPT 5 packets, 356 bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 4 packets, 384 bytes) pkts bytes target prot opt in out source destination [Execution of orders]#getenforce Enforcing [Execution of orders]#setenforce 0 // Suggested closing selinux to avoid affecting the experimental results [Execution of orders]#getenforce Permissive [Execution of orders]#System CTL stop firewalld. service // / If ftp is still inaccessible, you can shut down the firewall service directly [Execution of orders]#systemctl disable firewalld.service [Execution of orders]#systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
2. Copy metadata repodata and rpm package files to the directory of network services, and the client can access them remotely.
cd /var/ftp/pub/ ls mkdir 6 7 cd 7 cp -r /mnt/repodata . ls repodata/ mkdir Packages cp -r /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm Packages/ ls Packages/ ls cd ../6 mkdir Packages umount /dev/sr0 ls /mnt/ mount /dev/sr0 /mnt ls df -h mount /dev/sr0 /mnt cp -r /mnt/repodata . ls cp /mnt/Packages/tree-1.5.3-3.el6.x86_64.rpm Packages/ ls cd
The list of directories and files is shown as follows. yum sources of centos6 and 7 are built here. In order to test each of them, only one rpm package is copied. If you want to build a complete environment, you need to copy all the packages under CD Packages.
[Execution of orders]#ls /var/ftp/pub 6/ 7/ test.txt [Execution of orders]#ll /var/ftp/pub/6/Packages/ total 40 drwxr-xr-x. 2 root root 41 Jun 12 20:10 ./ drwxr-xr-x. 4 root root 38 Jun 12 20:09 ../ -r--r--r--. 1 root root 36884 Jun 12 20:10 tree-1.5.3-3.el6.x86_64.rpm [Execution of orders]#ll /var/ftp/pub/7/Packages/ total 48 drwxr-xr-x. 2 root root 42 Jun 12 20:07 ./ drwxr-xr-x. 4 root root 38 Jun 12 20:06 ../ -rw-r--r--. 1 root root 47508 Jun 12 20:07 tree-1.6.0-10.el7.x86_64.rpm [Execution of orders]#ll /var/ftp/pub/6/repodata/ total 27064 dr-xr-xr-x. 2 root root 4096 Jun 12 20:09 ./ drwxr-xr-x. 4 root root 38 Jun 12 20:09 ../ -r--r--r--. 1 root root 6621696 Jun 12 20:09 4344a2a6bf5b36982d263c6bdd097cb92e57910dee985a1ab445609788600c0d-filelists.sqlite.bz2 -r--r--r--. 1 root root 4880323 Jun 12 20:09 4bdfb96905d87533542b3d8b5f9b60c3909ceffa99eb7a3f873adbdee907bf1c-primary.sqlite.bz2 -r--r--r--. 1 root root 2893552 Jun 12 20:09 59379012d189411213fb362e26b449fe6bd49949bf184e77285ec36154f65074-other.sqlite.bz2 -r--r--r--. 1 root root 3145272 Jun 12 20:09 71569ab4b90fb6a4855e9a2f63f17f284f6d6a224773450e135f92816308b447-other.xml.gz -r--r--r--. 1 root root 231283 Jun 12 20:09 aa8289f99bf8aedf9426be9da6339eed4db430a72d9740b4a502cb1ec150aff8-c6-x86_64-comps.xml.gz -r--r--r--. 1 root root 1260372 Jun 12 20:09 d0df041d26b67f7e9b5c5828e5126ddbfeb3a998ec8e8426de2d260d8e 15f6-c6-x86_64-comps.xml ▽r--r--r--. 1 root root 2776232 Jun 12 20:09 d3b2352ce1e09ca85dc0897d47c381be1beacd93f33b88a584a3c7ae8b725a5e-primary.xml.gz -r--r--r--. 1 root root 5879460 Jun 12 20:09 f9a33e31c3fb73eab7900fa086b25220d412c0618bf4596c22b325bf9a4832fe-filelists.xml.gz -r--r--r--. 1 root root 4063 Jun 12 20:09 repomd.xml -r--r--r--. 1 root root 2575 Jun 12 20:09 TRANS.TBL [Execution of orders]#ll /var/ftp/pub/7/repodata/ total 13708 drwxr-xr-x. 2 root root 4096 Jun 12 20:06 ./ drwxr-xr-x. 4 root root 38 Jun 12 20:06 ../ -rw-r--r--. 1 root root 1495137 Jun 12 20:06 5635df73647e7bb1ac9a289c27f3a84db1db2e33d3644bf506b85562c2a3d392-primary.xml.gz -rw-r--r--. 1 root root 3103702 Jun 12 20:06 6ec2bb89ebc4b716fe62ea930164b179f2cd90e1bdf1a504cdd7832153392b1e-filelists.sqlite.bz2 -rw-r--r--. 1 root root 3069068 Jun 12 20:06 889dab2d016c523397f24315cacb947484b06607924cc7e4716017842515df52-filelists.xml.gz -rw-r--r--. 1 root root 971157 Jun 12 20:06 8d04a279fb66b24cab67e8ebc33ef0ddb4fd7d37f9d9608585598a1b80138f53-other.xml.gz -rw-r--r--. 1 root root 3122198 Jun 12 20:06 b1b2cb9f67759ef5d143a211c2399d800fa58cf3ab12c205188e3c13d1b3d41d-primary.sqlite.bz2 -rw-r--r--. 1 root root 159099 Jun 12 20:06 c55e5b7bbe933fa8dac2cffca4596c265812b74ed12ef3968d487dd6eb22ad93-c7-x86_64-comps.xml.gz -rw-r--r--. 1 root root 748686 Jun 12 20:06 d918936f5019be3fb66e9981a28cb2a41477a2963d741d454f79377a22214f43-c7-x86_64-comps.xml -rw-r--r--. 1 root root 1339096 Jun 12 20:06 e4e51f819c9dfc35ad68a2745f1e39020d003741cbb1346d93f776d13e44351c-other.sqlite.bz2 -rw-r--r--. 1 root root 3732 Jun 12 20:06 repomd.xml -r--r--r--. 1 root root 2575 Jun 12 20:06 TRANS.TBL
3. Configure client YUM source, test and install software
yum client configuration file:
[ftpbase]// Can't rename
name=centos7 // / description information
baseurl=URL //http,ftp,file file path
enabled={1|0} //1 enabled, 0 disabled
gpgcheck={1|0}// Whether to Open Verification
[Execution of orders]#Mkdir/etc/yum.repos.d/back//First you need to back up the original *.repo file [Execution of orders]#cd /etc/yum.repos.d/back [Execution of orders]#mv C* back/ [Execution of orders]#vi /etc/yum.repos.d/ftp.repo [ftpbase] name=ftp yum server baseurl=ftp://192.168.x.x/pub/$releasever gpgcheck=0 [Execution of orders]#yum repolist // query yum source set successfully Loaded plugins: fastestmirror, langpacks ftpbase | 3.6 kB 00:00:00 (1/2): ftpbase/7/group_gz | 155 kB 00:00:00 (2/2): ftpbase/7/primary_db | 3.0 MB 00:00:00 Loading mirror speeds from cached hostfile repo id repo name status ftpbase/7 ftp yum server 3,831 repolist: 3,831 [Execution of orders]#rpm -qa tree tree-1.6.0-10.el7.x86_64 [Execution of orders]#rpm -e tree [Execution of orders]#tree bash: tree: command not found... [Execution of orders]#yum install tree // / install software through yum source Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Installing: tree x86_64 1.6.0-10.el7 base 46 k Transaction Summary ======================================================================================================= Install 1 Package Total download size: 46 k Installed size: 87 k Is this ok [y/d/N]: y Downloading packages: tree-1.6.0-10.el7.x86_64.rpm | 46 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. Installing : tree-1.6.0-10.el7.x86_64 1/1 Verifying : tree-1.6.0-10.el7.x86_64 1/1 Installed: tree.x86_64 0:1.6.0-10.el7 Complete! [Execution of orders]#yum list | grep tree // / Check if the software has been installed successfully tree.x86_64 1.6.0-10.el7 @base texlive-pst-tree.noarch 2:svn24142.1.12-38.el7 base [Execution of orders]#cd [Execution of orders]#yum remove tree // uninstall software Loaded plugins: fastestmirror, langpacks Resolving Dependencies --> Running transaction check ---> Package tree.x86_64 0:1.6.0-10.el7 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================= Package Arch Version Repository Size ======================================================================================================= Removing: tree x86_64 1.6.0-10.el7 @base 87 k Transaction Summary ======================================================================================================= Remove 1 Package Installed size: 87 k Is this ok [y/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Erasing : tree-1.6.0-10.el7.x86_64 1/1 Verifying : tree-1.6.0-10.el7.x86_64 1/1 Removed: tree.x86_64 0:1.6.0-10.el7 Complete! [Execution of orders]#tree -bash: /usr/bin/tree: No such file or directory
Experiment 2: Implementing third-party YUM source
1. Setting up network service, the client can access the network remotely normally. Experiment 1 has been implemented, which is omitted here.
2. Copy third-party software to the directory of network services and create metadata
umount /mnt df -h mount /dev/sr0 /mnt ls /mnt/ cd /var/ftp/pub/ mkdir app cp /mnt/Packages/tree-1.6.0-10.el7.x86_64.rpm app cd createrepo /var/ftp/pub/app/ //Create metadata repodata through the creatrepo command cd /var/ftp/pub/app/ ls repodata/ cd
3. Configure client YUM source, test and install software
[Execution of orders]#vi /etc/yum.repos.d/ftp.repo [app] name=app yum server baseurl=ftp://192.168.10.14/pub/app gpgcheck=0 [Execution of orders]#yum repolist [Execution of orders]#yum install tree.x86_64// / test installation software
Experiment 3: Source code compilation and installation of Apache
1. Download Apache source package and decompress it
tar -xvf httpd-2.4.25.tar.bz2 ls cd httpd-2.4.25/ ls
2. Install Development Tools for the Development Toolkit Group
[Execution of orders]#Vi/etc/yum.repos.d/ftp.repo//Change Yum source to CD [cdrom] name=cdrom yum baseurl=file:///mnt gpgcheck=0 [Execution of orders]#yum repolist yum groups install Development\ Tools install devel Packet group
3. Check the README and INSTALL help files to determine the parameter settings for compilation and installation
more README
more INSTALL
4.configure, that is to configure the installation path and parameters, if there is an error, then install the corresponding package. Generally, add - devel to the prompted file name is the package name that needs to be installed, such as
rpm -qa filename
yum search filename
yum install filename-devel
./configure --prefix=/app/apache24 //Hint dependencies, lack of apr packages rpm -qa apr //Query which rpm package file the apr comes from yum search apr //Query whether the yum source has this package file, as shown below Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile ========================================== N/S matched: apr =========================================== apr-devel.x86_64 : APR library development kit apr-util-devel.x86_64 : APR utility library development kit apr.x86_64 : Apache Portable Runtime library apr-util.x86_64 : Apache Portable Runtime Utility library haproxy.x86_64 : TCP/HTTP proxy and load balancer for high availability environments Name and summary matches only, use "search all" for everything. yum install apr-devel //Install the package file, named apr-devel ./configure --prefix=/app/apache24 //Continue the configuration process //Suggest the lack of apr-util package, repeat the above operations, and solve all dependency problems in turn rpm -qa apr-util yum search apr-util yum install apr-util-devel ./configure --prefix=/app/apache24 rpm -qa pcre-config rpm -qa pcre yum search pcre yum install pcre-devel ./configure --prefix=/app/apache24 //Successful configuration
5. make & make install, compile and install
cd cd httpd-2.4.25/ ls make && make install //Compile and install httpd
6. Start the service and test whether the software is installed successfully
cd /app/apache24/ iptables -vnL /app/apache24/bin/apachectl start netstat -ntl cd /app/apache24/htdocs/ //Here is the directory for the website. ls
The test page shows "it works!"
Startup files for httpd can be added to the PATH directory so that they can run directly without specifying an absolute path.
echo "PATH=$PATH:$dirname/bin" > /etc/profile.d/apache2.sh;cd /etc/profile.d/;. apache2.sh;cd
Next time you can run the command directly
apachectl start | stop | restart | status