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

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

off999 2025-03-19 15:35 23 浏览 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-fire 快速构建 CLI_如何搭建python项目架构

命令行应用程序是开发人员最好的朋友。想快速完成某事?只需敲击几下键盘,您就已经拥有了想要的东西。Python是许多开发人员在需要快速组合某些东西时选择的第一语言。但是我们拼凑起来的东西在大多数时候并...

Python 闭包:从底层逻辑到实战避坑,附安全防护指南

一、闭包到底是什么?你可以把闭包理解成一个"带记忆的函数"。它诞生时会悄悄记下自己周围的变量,哪怕跑到别的地方执行,这些"记忆"也不会丢失。就像有人出门时总会带上...

使用Python实现九九乘法表的打印_用python打印一个九九乘法表

任务要求九九乘法表的结构如下:1×1=11×2=22×2=41×3=32×3=63×3=9...1×9=92×9=18...9×9=81使用Python编写程序,按照上述格式打印出完整的九...

吊打面试官(四)--Java语法基础运算符一文全掌握

简介本文介绍了Java运算符相关知识,包含运算规则,运算符使用经验,特殊运算符注意事项等,全文5400字。熟悉了这些内容,在运算符这块就可以吊打面试官了。Java运算符的规则与特性1.贪心规则(Ma...

Python三目运算基础与进阶_python三目运算符判断三个变量

#头条创作挑战赛#Python中你学会了三步运算,你将会省去很多无用的代码,我接下来由基础到进阶的方式讲解Python三目运算基础在Python中,三目运算符也称为条件表达式。它可以通过一行代码实现条...

Python 中 必须掌握的 20 个核心函数——set()详解

set()是Python中用于创建集合的核心函数,集合是一种无序、不重复元素的容器,非常适合用于成员检测、去重和数学集合运算。一、set()的基本用法1.1创建空集合#创建空集合empty_se...

15个让Python编码效率翻倍的实用技巧

在软件开发领域,代码质量往往比代码数量更重要。本文整理的15个Python编码技巧,源自开发者在真实项目中验证过的工作方法,能够帮助您用更简洁的代码实现更清晰的逻辑。这些技巧覆盖基础语法优化到高级特性...

《Python从小白到入门》自学课程目录汇总(和猫妹学Python)

小朋友们好,大朋友们好!不知不觉,这套猫妹自学Python基础课程已经结束了,猫妹体会到了水滴石穿的力量。水一直向下滴,时间长了能把石头滴穿。只要坚持不懈,细微之力也能做出很难办的事。就比如咱们的学习...

8÷2(2+2) 等于1还是16?国外网友为这道小学数学题吵疯了……

近日,国外网友因为一道小学数学题在推特上争得热火朝天。事情的起因是一个推特网友@pjmdoll发布了一条推文,让他的关注者解答一道数学题:Viralmathequationshavebeen...

Python学不会来打我(21)python表达式知识点汇总

在Python中,表达式是由变量、运算符、函数调用等组合而成的语句,用于产生值或执行特定操作。以下是对Python中常见表达式的详细讲解:1.1算术表达式涉及数学运算的表达式。例如:a=5b...

Python运算符:数学助手,轻松拿咧

Python中的运算符就像是生活中的数学助手,帮助我们快速准确地完成这些计算。比如购物时计算总价、做家务时分配任务等。这篇文章就来详细聊聊Python中的各种运算符,并通过实际代码示例帮助你更好地理解...

Python学不会来打我(17)逻辑运算符的使用方法与使用场景

在Python编程中,逻辑运算符(LogicalOperators)是用于组合多个条件表达式的关键工具。它们可以将多个布尔表达式连接起来,形成更复杂的判断逻辑,并返回一个布尔值(True或Fa...

Python编程基础:运算符的优先级_python中的运算符优先级问题

多个运算符同时出现在一个表达式中时,先执行哪个,后执行哪个,这就涉及运算符的优先级。如数学表达式,有+、-、×、÷、()等,优先级顺序是()、×、÷、+、-,如5+(5-3)×4÷2,先计算(5-3)...

Python运算符与表达式_python中运算符&的功能

一、运算符分类总览1.Python运算符全景图2.运算符优先级表表1.3.1Python运算符优先级(从高到低)优先级运算符描述结合性1**指数右→左2~+-位非/一元加减右→左3*//...

Python操作Excel:从基础到高级的深度实践

Python凭借其丰富的库生态系统,已成为自动化处理Excel数据的强大工具。本文将深入探讨五个关键领域,通过实际代码示例展示如何利用Python进行高效的Excel操作,涵盖数据处理、格式控制、可视...

取消回复欢迎 发表评论: