Linux 操作练习项目

编译安装三部曲 说明

./configure 对软件进行功能配置,指定安装目录,开启或关闭功能
make 根据上一步的配置,进行编译(c语言代码二进制文件(命令))
make install 安装(创建目录,命令,配置文件复制到指定目录)

老男孩教育-王牌班-83期-操作练习项目

搭建堡垒机 难度 1

编译安装nginx搭建小游戏网站. 难度 5
二进制方式安装Tomcat 难度 2
搭建内部yum仓库. 难度 9

1. 编译安装nginx搭建小游戏网站

1.1 编译安装流程

下载nginx代码

解压并进入目录

配置

wget -P /server/tools/ http:nginx.org/download/nginx-
1.22.0.tar.gz

1

cd /server/tools/
tar xf nginx-1.22.0.tar.gz
cd nginx-1.22.0/

1

2

3

4

成功提示:

错误提示:

./configure  prefix=/app/nginx-1.22.0/ user=nginx 
group=nginx with-http_ssl_module with-http_v2_module
with-http_stub_status_module
#prefix指定安装目录
user 用户
group 用户组

1 2 3 4 5 6 7 8

编译

成功提示

安装

./configure: error: the HTTP rewrite module requires the
PCRE library.
You can either disable the module by using without-
http_rewrite_module
option, or install the PCRE library into the system, or
build the PCRE library
statically from the source with nginx by using with-
pcre=<path> option.
yum install -y pcre-devel

1 2 3 4 5 6

./configure: error: SSL modules require the OpenSSL
library.
You can either do not enable the modules, or install the
OpenSSL library
into the system, or build the OpenSSL library statically
from the source
with nginx by using with-openssl=<path> option.
yum install -y openssl-devel

1

2

3

4

5

1 make

编程安装完成

1.2 后续配置

检查目录

创建用户

创建软连接

1.3 管理编译安装的nginx

温馨提示:关闭防火墙和selinux.
1 make install
ll /app/nginx-1.22.0/
总用量 0
drwxr-xr-x 2 root root 333 7 月  29 12 :10 conf
drwxr-xr-x 2 root root 40 7 月  29 12 :10 html
drwxr-xr-x 2 root root 6 7 月  29 12 :10 logs
drwxr-xr-x 2 root root 19 7 月  29 12 :10 sbin

1 2 3 4 5 6

1 useradd -s /sbin/nologin  -M nginx
ln -s /app/nginx-1.22.0/ /app/nginx
并检查

1

2

1 #1. 查看nginx版本信息及编译信息

检查端口nginx

ss -lntup |grep nginx

/app/nginx/sbin/nginx -V
nginx version: nginx/1.22.
built by gcc 4 .8.5 20150623 (Red Hat 4 .8.5-44) (GCC)
built with OpenSSL 1 .0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: prefix=/app/nginx-1.22.0/ 
user=nginx group=nginx with-http_ssl_module with-
http_v2_module with-http_stub_status_module
#2.启动nginx
/app/nginx/sbin/nginx
ps aux |grep nginx
#3. 关闭
pkill nginx

2 3 4 5 6 7 8 9

10

11

12

13

14

15

nginx: [emerg] bind() to 0 .0.0.0:80 failed (98: Address
already in use)
nginx: [emerg] bind() to 0 .0.0.0:80 failed (98: Address
already in use)
nginx: [emerg] bind() to 0 .0.0.0:80 failed (98: Address
already in use)
nginx: [emerg] bind() to 0 .0.0.0:80 failed (98: Address
already in use)
nginx已经运行了并占用 80 端口

1

2

3

4

5

1.4 访问网站

浏览器中输入服务器ip地址即可:10.0.0.200  http:10.0.0.200:

1.5 配置代码

代码目录/app/nginx/html/下面 默认显示index.html内容
修改index.html内容刷新浏览器就可以查看改变

1.6 部署小鸟飞飞代码

1 启动nginx并检查
2

#1. 解压

unzip bird.zip
#2. 移动
\mv bird /app/nginx/html/
#3. 检查
ll /app/nginx/html/

1 2 3 4 5 6 7

检查最终结果

2. 二进制方式安装Tomcat

2.1 部署tomcat

安装jdk (使用java程序或代码必会工具)
下载tomcat
解压
创建软连接
启动

总用量 144

-rw-rr 1 root root 15329 8  2 2014 2000 .png
-rw-rr 1 root root 51562 8  2 2014 21 .js
-rw-rr 1 root root 497 7   29 12 :10 50x.html
-rw-rr 1 root root 254 8  2 2014 icon.png
drwxr-xr-x 2 root root 102 8  8 2014 img
-rw-rr 1 root root 3049 8  2 2014 index.html
-rw-rr 1 root root 63008 8  2 2014 sound1.mp

8

9

10

11

12

13

14

15

16

查看

安装jdk

下载

解压

软连接

1 yum install -y java  #openjdk

wget -P /server/tools/
https:dlcdn.apache.org/tomcat/tomcat-
9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz

1

https:mirrors.aliyun.com/apache/
下载地址:
https:mirrors.aliyun.com/apache/tomcat/tomcat-
9/v9.0.65/bin/?spm=a2c6h.25603864.0.0.1bca5120a32WtZ
wget -P /server/tools/
https:mirrors.aliyun.com/apache/tomcat/tomcat-
9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz

1

2

3

4

5

1 tar xf apache-tomcat-9.0.65.tar.gz  -C /app/

1 ln -s /app/apache-tomcat-9.0.65/ /app/tomcat

2.2 启动与访问

启动

检查端口与进程

浏览器访问: http:10.0.0.200:
/app/tomcat/bin/startup.sh
/app/tomcat/bin/shutdown.sh

1

2

3

ps -ef |grep java
ss -lntup |grep java

1

2

3

4

yum仓库服务端操作步骤 10.0.0.
 准备软件仓库的目录,解压软件包到这个目录中 ✅
 通过creatrepo在这个目录中生成rpm包列表(属性信息
文件) ✅
repodata目
录
 安装nginx,修改ngx配置可以访问 /app/yumlocal/
目录 ✅^
 测试浏览器访问

3. 搭建企业内部yum仓库

3.1 yum仓库架构详解

自己搭建内部yum仓库.
yum仓库客户端 10.0.0.
 注释掉已经有的yum源配置文件.
 修改配置访问10.0.0.200的yum仓库

3.2 yum仓库服务端

创建目录

解压软件包到/app/yumlocal目录下
通过creatrepo在这个目录中生成rpm包列表(属性信息文件)
安装与配置nginx
1 /app/yumlocal
1 php72w-new.tar.gz
yum install -y createrepo
createrepo /app/yumlocal/
目录下面就多了个repodata目录.

1

2

3

#关闭已有的nginx
pkill nginx
ps -ef |grep nginx
#安装
yum install -y nginx
#启动
systemctl enable nginx
systemctl start nginx

1 2 3 4 5 6 7 8 9

10

配置nginx
浏览器访问测试 http:10.0.0.200:

#检查端口与进程

#浏览器访问

11

12

13

14

[root@oldboy83-prod tools]# cat
/etc/nginx/conf.d/yumlocal.conf
server {
listen 12306 ;
root /app/yumlocal;
autoindex on;
index index.html;
}
systemctl restart nginx
ss -lntup |grep nginx
tcp LISTEN 0  128 *:
*:* users:(("nginx",pid= 10460 ,fd= 6 ),
("nginx",pid= 10458 ,fd= 6 ))
tcp LISTEN 0  128 *:
*:* users:(("nginx",pid= 10460 ,fd= 7 ),
("nginx",pid= 10458 ,fd= 7 ))
tcp LISTEN 0  128 []:
[]:* users:(("nginx",pid= 10460 ,fd= 8 ),
("nginx",pid= 10458 ,fd= 8 ))

1 2 3 4 5 6 7 8 9

10

11

12

13

14

1

3.3 yum客户端配置

注释已经配置的yum源文件
书写新的yum配置即可
测试是否可以使用内部yum仓库
cd /etc/yum.repos.d/
gzip *

1

2

3

cat yumlocal-10.0.0.200.repo
[yumlocal]
name = 'yum local 内部yum源 10.0.0.200'
baseurl = http:10.0.0.200:
enalbed = 1
gpgcheck = 0

1 2 3 4 5 6 7

#1.清空缓存

yum clean all
Loaded plugins: fastestmirror
Cleaning repos: yumlocal

1

2

3

4

3.4 遇到下载失败或依赖问题

服务端: 需要在服务端下载依赖,上传到目录中

服务端: 重新createrepo
客户端: yum clean all 然后yum makecache 然后 yum install
Cleaning up list of fastest mirrors
Other repos take up 183 M of disk space (use verbose for
details)
#2.根据新的配置生成缓存
yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
yumlocal
| 2 .9 kB 00 :00:
(1/3): yumlocal/filelists_db
| 13 kB 00 :00:
(2/3): yumlocal/other_db
| 5 .3 kB 00 :00:
(3/3): yumlocal/primary_db
| 22 kB 00 :00:
Metadata Cache Created
#3. 查看yum源列表
yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name
status
yumlocal  'yum local 内部
yum源 10.0.0.200'  
repolist: 20

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

服务端: 需要在服务端下载依赖,上传到目录中

服务端: 重新createrepo
客户端: yum clean all 然后yum makecache 然后 yum install
#1. 开启keepcache功能
grep keepcache /etc/yum.conf
#2. 进入软件包目录
cd /app/yumlocal/
#3. 本地安装并下载依赖
yum localinstall -y *.rpm
#4. 找出缓存的rpm包
find /var/cache/yum/ -type f -name "*.rpm"
#4.找出缓存的rpm包并复制到/app/yumlocal/目录
find /var/cache/yum/ -type f -name "*.rpm" |xargs cp -t
/app/yumlocal/
ll /app/yumlocal/*.rpm |wc -l

1 2 3 4 5 6 7 8 9

10

11

#5. 重新生成

createrepo /app/yumlocal/

1

2

yum clean all
yum makecache
yum repolist
yum install -y php72w-cli

1

2

3

4

posted @   rbcd  阅读(4)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示