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

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

gudong366 2025-06-20 16:53 8 浏览

编译安装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=<path> 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=<path> 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服务器

大家好,之前给大家介绍一个一款可以用来备份还原、远程克隆、P2V、V2V的工具--再生龙,今天就来给大家演示如何用该工具来远程克隆一台linux服务器。使用此方法,可以将一台物理服务器远程克隆到虚拟...

Linux 下用 SSH 登录远程服务器后把远程服务器文件传本地电脑

在Linux下,使用SSH命令登录远程服务器后,可以使用scp命令将远程服务器上的文件复制到本地电脑。以下是scp命令的基本用法:scp[用户名]@[远程服务器地址]:[远程文件路径][本地存放路...

一文掌握怎么利用Shell+Python实现Linux系统数据异地备份程序

简介:在当今的信息化时代,数据安全已成为企业和个人运维的重中之重。无论是服务器宕机、硬盘损坏,还是遭遇勒索病毒,数据丢失都可能带来巨大损失。为了最大程度保障数据安全,异地备份成为了最佳实践之一。本文将...

如何在Linux上搭建本地Docker Registry并实现远程连接

在Linux上搭建本地DockerRegistry并实现远程连接,可以按照以下步骤操作:一、安装Docker确保Linux系统上已经安装了Docker。如果尚未安装,可以使用以下命令进行安装(以Ub...

服务器连接方法教程(服务器地址怎么连接)

连接服务器的方式多种多样,具体取决于服务器的类型、操作系统以及你的使用需求。以下是几种常见的服务器连接方法,包含详细步骤和注意事项:一、远程桌面连接(适用于Windows服务器)适用场景:需要图形...

自动化测试学习:使用python库Paramiko实现远程服务器上传和下载

前言测试过程中经常会遇到需要将本地的文件上传到远程服务器上,或者需要将服务器上的文件拉到本地进行操作,以前安静经常会用到xftp工具。今天安静介绍一种python库Paramiko,可以帮助我们通过代...

手把手教你安装、远程连接Ubuntu 22.04

Ubuntu分为桌面版和服务器版本,我们选择服务器版本1下载Ubuntu22.04Ubuntu22.04下载地址:https://releases.ubuntu.com/22.04/ubuntu...

Windows服务器怎么连接?远程连接服务器命令

服务器操作系统可以实现对计算机硬件与软件的直接控制和管理协调,任何计算机的运行离不开操作系统,服务器也一样,服务器操作系统主要分为四大流派:WindowsServer、Netware、Unix和Li...

如何使用JuiceSSH实现手机端远程连接Linux服务器

在当今数字化时代,远程连接到服务器成为了许多人工作和生活中的必需品。JuiceSSH是一款比较强大的Android应用程序,它可以让您在手机上轻松地远程连接到Linux服务器。下面简单的向您介绍如何使...

本地电脑如何远程连接服务器(电脑如何远程桌面连接服务器)

下面就来说说如何远程登录服务器。服务器一般有两大类系统,一种是windows系统,一种是Linux系统。下面以Windows系统为例1、Windows系统有自带的登录系统,点击“运行”(或者windo...

如何用CHAT配置linux的远程连接?(chattr linux)

问CHAT:配置linux的远程连接1.下载ssh2.启动ssh服务3.查看ssh服务状态4.设置ssh服务开机自启动5.设置windows的cmd下ssh6.通过cmd的ssh命令远程到...

服务器怎么远程连接控制(服务器远程桌面连接设置方法)

我是艾西,还是有很多小白同学问我服务器怎么远程连接。那么今天我们重点来教教大家如何用电脑远程服务器配上图文教程,让不懂的新手小白一看就会,分分钟上手教程远程服务器需要一台电脑俗称“PC”就是我们自己平...

如何远程管理Linux服务器(linux远程登录管理)

在当今数字化的时代,Linux服务器凭借其稳定性和高效性,成为众多企业和开发者的首选。然而,很多时候我们无法直接在服务器前操作,这就需要掌握远程管理Linux服务器的技巧啦。别担心,今天就来给大家分享...

Linux系统无法启动?别慌!这可能是全网最全的故障排查攻略

当Linux系统罢工时,盲目重装只会浪费时间!本文整理8种常见故障的解决方案,涵盖从引导修复到硬件检测全流程,建议收藏备用。一、引导阶段故障排查1.GRUB引导丢失现象:黑屏显示"grub&...

Linux进程管理(linux进程管理实验报告)

原作者:Linux教程,原文「链接」:https://mp.weixin.qq.com/s/39rQMl3V2Egot9cZ14NCLg【获得原作者转载授权】每个计算机系统都包含一个核心软件集合,即操...