百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术资源 > 正文

干货 | 这 3 个超经典的Linux实战项目,让你分分钟入门Linux系统

off999 2025-03-19 15:35 18 浏览 0 评论

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

编译安装流程

下载nginx代码

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

解压并进入目录

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

配置

./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 用户组

成功提示:

错误提示:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using withouthttp_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= option.

yum install -y pcre-devel
./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= option.

yum install -y openssl-devel

编译make成功提示:

安装:

make install

后续配置

检查目录

ll /app/nginx-1.22.0/ 
总用量 0 
drwxr-xr-x 2 root root 333 7月 
drwxr-xr-x 2 root root 40 7月 
drwxr-xr-x 2 root root 6 7月 
drwxr-xr-x 2 root root 19 7月

创建用户

useradd -s /sbin/nologin   -M nginx

创建软链接

ln -s /app/nginx-1.22.0/   /app/nginx
并检查

管理编译安装的nginx

温馨提示:关闭防火墙和selinux

#1. 查看nginx版本信息及编译信息
/app/nginx/sbin/nginx -V nginx version: nginx/1.22.0 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 withhttp_v2_module with-http_stub_status_module

#2.启动nginx 
/app/nginx/sbin/nginx ps aux |grep nginx

#3. 关闭 
pkill nginx
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端口
检查端口nginx

ss -lntup |grep nginx

访问网站

启动nginx并检查:浏览器中输入服务器ip地址即可

配置代码

代码目录/app/nginx/html/下面 默认显示index.html内容

代码目录/app/nginx/html/下面 默认显示index.html内容

配置小鸟飞飞代码

#1. 解压 
unzip bird.zip 
#2. 移动 
\mv bird/* /app/nginx/html/

#3. 检查 
ll /app/nginx/html/

总用量 144

-rw-r--r-- 1 root root 15329 8月  2 2014 2000.png

-rw-r--r-- 1 root root 51562 8月  2 2014 21.js

-rw-r--r-- 1 root root 497 7月  29 12:10 50x.html

-rw-r--r-- 1 root root 254 8月  2 2014 icon.png

drwxr-xr-x 2 root root 102 8月  8 2014 img

-rw-r--r-- 1 root root 3049 8月  2 2014 index.html

-rw-r--r-- 1 root root 63008 8月  2 2014 sound1.mp3

检查最终结果

二进制方式安装Tomcat

部署tomcat

安装jdk

yum install -y java #openjdk

下载

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

https://mirrors.aliyun.com/apache/ 
下载地址: 
https://mirrors.aliyun.com/apache/tomcat/tomcat9/v9.0.65/bin/?spm=a2c6h.25603864.0.0.1bca5120a32WtZ

wget -P /server/tools/ https://mirrors.aliyun.com/apache/tomcat/tomcat9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz

解压

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

软连接

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

启动与访问

启动

/app/tomcat/bin/startup.sh

/app/tomcat/bin/shutdown.sh

检查端口与进程

ps -ef |grep java

ss -lntup |grep java

浏览器访问: http://10.0.0.200:8080

搭建企业内部yum仓库

yum仓库架构详解

自己搭建内部yum仓库

yum仓库服务端

创建目录

/app/yumlocal

解压软件包到/app/yumlocal目录下

php72w-new.tar.gz

通过creatrepo在这个目录中生成rpm包列表(属性信息文件)

yum install -y createrepo 
createrepo /app/yumlocal/ 
目录下面就多了个repodata目录.

安装与配置nginx

#关闭已有的
nginx pkill nginx ps -ef |grep nginx

#安装 
yum install -y nginx

#启动 
systemctl enable nginx systemctl start nginx

#检查端口与进程

#浏览器访问

配置nginx

[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 *:12306
*:* users:(("nginx",pid=10460,fd=6),
("nginx",pid=10458,fd=6))
tcp LISTEN 0 128 *:80
*:* users:(("nginx",pid=10460,fd=7),
("nginx",pid=10458,fd=7))
tcp LISTEN 0 128 [ ]:80
[ ]:* users:(("nginx",pid=10460,fd=8),
("nginx",pid=10458,fd=8))

浏览器访问测试 http: 10.0.0.200:12306

yum客户端配置

注释已经配置的yum源文件

cd /etc/yum.repos.d/ 
gzip *

书写新的yum配置即可

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

测试是否可以使用内部yum仓库

#1.清空缓存
yum clean all
Loaded plugins: fastestmirror
Cleaning repos: yumlocal

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:00
(1/3): yumlocal/filelists_db
| 13 kB 00:00:00
(2/3): yumlocal/other_db
| 5.3 kB 00:00:00
(3/3): yumlocal/primary_db
| 22 kB 00: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' 20
repolist: 20

遇到下载失败或依赖问题

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

#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

服务端:重新createrepo

#5. 重新生成
createrepo /app/yumlocal/

服务端:yum clean all 然后 yum makecache 然后 yum install

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

企业级SRE运维必会项目

【学习资料+视频教程合集】

免费领取,限 200

评论区告诉我!!!

相关推荐

Python钩子函数实现事件驱动系统(created钩子函数)

钩子函数(HookFunction)是现代软件开发中一个重要的设计模式,它允许开发者在特定事件发生时自动执行预定义的代码。在Python生态系统中,钩子函数广泛应用于框架开发、插件系统、事件处理和中...

Python函数(python函数题库及答案)

定义和基本内容def函数名(传入参数):函数体return返回值注意:参数、返回值如果不需要,可以省略。函数必须先定义后使用。参数之间使用逗号进行分割,传入的时候,按照顺序传入...

Python技能:Pathlib面向对象操作路径,比os.path更现代!

在Python编程中,文件和目录的操作是日常中不可或缺的一部分。虽然,这么久以来,钢铁老豆也还是习惯性地使用os、shutil模块的函数式API,这两个模块虽然功能强大,但在某些情况下还是显得笨重,不...

使用Python实现智能物流系统优化与路径规划

阅读文章前辛苦您点下“关注”,方便讨论和分享,为了回馈您的支持,我将每日更新优质内容。在现代物流系统中,优化运输路径和提高配送效率是至关重要的。本文将介绍如何使用Python实现智能物流系统的优化与路...

Python if 语句的系统化学习路径(python里的if语句案例)

以下是针对Pythonif语句的系统化学习路径,从零基础到灵活应用分为4个阶段,包含具体练习项目和避坑指南:一、基础认知阶段(1-2天)目标:理解条件判断的逻辑本质核心语法结构if条件:...

[Python] FastAPI基础:Path路径参数用法解析与实例

查询query参数(上一篇)路径path参数(本篇)请求体body参数(下一篇)请求头header参数本篇项目目录结构:1.路径参数路径参数是URL地址的一部分,是必填的。路径参...

Python小案例55- os模块执行文件路径

在Python中,我们可以使用os模块来执行文件路径操作。os模块提供了许多函数,用于处理文件和目录路径。获取当前工作目录(CurrentWorkingDirectory,CWD):使用os....

python:os.path - 常用路径操作模块

应该是所有程序都需要用到的路径操作,不废话,直接开始以下是常用总结,当你想做路径相关时,首先应该想到的是这个模块,并知道这个模块有哪些主要功能,获取、分割、拼接、判断、获取文件属性。1、路径获取2、路...

原来如此:Python居然有6种模块路径搜索方式

点赞、收藏、加关注,下次找我不迷路当我们使用import语句导入模块时,Python是怎么找到这些模块的呢?今天我就带大家深入了解Python的6种模块路径搜索方式。一、Python模块...

每天10分钟,python进阶(25)(python进阶视频)

首先明确学习目标,今天的目标是继续python中实例开发项目--飞机大战今天任务进行面向对象版的飞机大战开发--游戏代码整编目标:完善整串代码,提供完整游戏代码历时25天,首先要看成品,坚持才有收获i...

python 打地鼠小游戏(打地鼠python程序设计说明)

给大家分享一段AI自动生成的代码(在这个游戏中,玩家需要在有限时间内打中尽可能多的出现在地图上的地鼠),由于我现在用的这个电脑没有安装sublime或pycharm等工具,所以还没有测试,有兴趣的朋友...

python线程之十:线程 threading 最终总结

小伙伴们,到今天threading模块彻底讲完。现在全面总结threading模块1、threading模块有自己的方法详细点击【threading模块的方法】threading模块:较低级...

Python信号处理实战:使用signal模块响应系统事件

信号是操作系统用来通知进程发生了某个事件的一种异步通信方式。在Python中,标准库的signal模块提供了处理这些系统信号的机制。信号通常由外部事件触发,例如用户按下Ctrl+C、子进程终止或系统资...

Python多线程:让程序 “多线作战” 的秘密武器

一、什么是多线程?在日常生活中,我们可以一边听音乐一边浏览新闻,这就是“多任务处理”。在Python编程里,多线程同样允许程序同时执行多个任务,从而提升程序的执行效率和响应速度。不过,Python...

用python写游戏之200行代码写个数字华容道

今天来分析一个益智游戏,数字华容道。当初对这个游戏颇有印象还是在最强大脑节目上面,何猷君以几十秒就完成了这个游戏。前几天写2048的时候,又想起了这个游戏,想着来研究一下。游戏玩法用尽量少的步数,尽量...

取消回复欢迎 发表评论: