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

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

ahcoder 2025-02-13 10:57 34 浏览

编译安装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

评论区告诉我!!!

相关推荐

linux服务器--PVE(一)简介及安装(pve安装ifupdown2)

1.PVE(ProxmoxVirtualEnvironment)简介ProxmoxVirtualEnvironment基于debian,是一个完整的、开源的企业虚拟化服务器管理平台。它在一个平...

手把手教你!如何在 Linux 服务器中搭建 Sentinel 环境?

你在Linux服务器上搭建Sentinel环境时,是不是也遇到过各种报错,要么是启动失败,要么是配置后无法正常访问控制台?看着同事顺利搭建好,自己却一头雾水,别提多着急了!其实,很多互联网大厂...

Linux高性能服务器技术总结(linux高性能服务器编程怎么样)

1服务器简介服务器是提供计算服务的设备,由于服务器需要响应用户请求,因此在处理能力、稳定性、安全性、可扩展性、可管理性等方面提出了较高要求。随着虚拟化技术的进步,云服务器(ECS)已经快速的在...

从 0 到 1:使用 Ansible 自动化运维 Linux 服务器全流程

Ansible是一款强大的IT自动化工具,广泛用于服务器配置管理、软件部署和任务自动化。本文将带你从零开始,学习如何使用Ansible对Linux服务器进行自动化运维,涵盖Ansibl...

诡异!Win11 “此电脑” 莫名现 Linux 图标,啥情况?

我这电脑出了个怪事儿,“此电脑”下面莫名其妙多了个Linux的图标,可我压根儿就没装过Linux系统啊!琢磨了一下,估计是系统可选功能里那个“适用于Linux的Windows子系统”插件搞的鬼。实例系...

Linux基础运维篇:Linux 终端与 Shell 基础(第006课)

一、啥是终端?先搞懂「人和电脑对话的窗口」你可以把终端(Terminal)理解成一个「文字版的电脑操作台」。在Windows里,类似「命令提示符」或PowerShell;在Linux里,...

2025罗技大师系列智「简」大赛-罗技大师系列-MX KEYS S键盘评测

在2025罗技大师系列智「简」大赛中,MXKEYSS键盘凭借其卓越的设计与智能化体验,成为众多创作者的理想之选。本篇文章将深入评测这款键盘的核心功能、使用体验及创新亮点,帮助你了解它如何提升...

Linux编辑命令vim(linux使用vim编辑文件)

1、vi编辑器简介vim是一个全屏幕纯文本编辑器,是vi编辑器的增强版,我们主要讲解的是vim编辑器。可以利用别名让输入vi命令的时候,实际上执行vim编辑器,例如:#定义别名...

全选是ctrl加什么?全选的快捷键是什么介绍

如何高效使用「全选」快捷键(Ctrl+A/A)提升工作效率在日常电脑操作中,"全选"是最基础却至关重要的功能之一。无论您是文字工作者、程序员还是普通用户,掌握全选快捷键都能极大提升操作...

Linux命令大全(linux命令大全书)

个人博客:https://chunyu.work/文章较长,可以收藏备用常用快捷键(1)ctrl+c:停止进程(2)ctrl+l:清屏(3)善于用tab键(4)上下键:查找执行过的命令文件目录类(...

Xshell是做什么用的?Xshell使用教程分享

Xshell是一款功能强大的终端模拟器,支持SSH1,SSH2,SFTP,TELNET,RLOGIN和SERIAL。通过提供业界先进的性能,Xshell包含了其他SSH客户端无法发现的功能和优势,作为...

Java 开发者线上问题排查常用的 15 个 Linux 命令

作为Java开发者,线上环境的问题排查是日常工作的重要组成部分。熟练掌握Linux命令能大幅提升排查效率,快速定位进程异常、日志错误、性能瓶颈等核心问题。本文结合Java应用特点,整理1...

Linux的常用命令就是记不住,怎么办?

1.帮助命令1.1help命令#语法格式:命令--help#作用:查看某个命令的帮助信息#示例:#ls--help查看ls命令的帮助信息#netst...

别再乱学 Linux 了!这 5 个核心技巧,让你效率飙升 10 倍!

在Linux学习的漫漫长路上,不少人犹如在黑暗中摸索的行者,四处碰壁,学习效果却不尽如人意。你是不是也曾在海量的Linux知识面前迷失方向,感觉自己投入了大量时间,却收效甚微?其实,掌握Li...

Linux终端神器Terminator时隔1年回归,2.1.5新版发布

IT之家5月23日消息,科技媒体linuxiac今天(5月23日)发布博文,报道称Terminator在沉寂一年后,最新发布了2.1.5版本,在分割终端窗格时支持克隆SSH...