新增:《内网CentOS服务器设置网络代理》
This commit is contained in:
@@ -17,7 +17,7 @@ tags:
|
||||
|
||||
### 查询系统详情
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 详细输出所有信息,依次为内核名称,主机名,内核版本号,内核版本,硬件名,处理器类型,硬件平台类型,操作系统名称
|
||||
uname -a
|
||||
```
|
||||
@@ -26,7 +26,7 @@ uname -a
|
||||
|
||||
### 查询系统发行版本
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 只适合Redhat系的Linux
|
||||
cat /etc/redhat-release
|
||||
```
|
||||
@@ -35,14 +35,14 @@ cat /etc/redhat-release
|
||||
|
||||
### 查看CPU信息
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 逻辑CPU数量和CPU型号
|
||||
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
|
||||
```
|
||||
|
||||

|
||||
|
||||
```bash
|
||||
```sh
|
||||
# CPU真实数量(有时候虽然逻辑CPU是8核,但可能是由两颗4核CPU构成的)
|
||||
cat /proc/cpuinfo | grep physical | uniq -c
|
||||
```
|
||||
@@ -51,7 +51,7 @@ cat /proc/cpuinfo | grep physical | uniq -c
|
||||
|
||||
### 查询RAM信息(内存)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 用于查看有关系统 RAM 使用情况的信息(带大小单位)
|
||||
free -h
|
||||
```
|
||||
@@ -60,13 +60,21 @@ free -h
|
||||
|
||||
### 查询ROM信息(磁盘)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 以磁盘分区为单位查看文件系统,可以获取硬盘被占用了多少空间,目前还剩下多少空间等信息
|
||||
df -h
|
||||
```
|
||||
|
||||

|
||||
|
||||
### 查询环境变量
|
||||
|
||||
```sh
|
||||
env
|
||||
# 过滤环境变量中的配置
|
||||
env | grep xxx
|
||||
```
|
||||
|
||||
## 防火墙相关
|
||||
|
||||
::: tip 已测试适用系统
|
||||
@@ -75,37 +83,37 @@ CentOS 7.5
|
||||
|
||||
### 查看防火墙状态
|
||||
|
||||
```bash
|
||||
```sh
|
||||
systemctl status firewalld
|
||||
```
|
||||
|
||||
### 开启防火墙
|
||||
|
||||
```bash
|
||||
```sh
|
||||
systemctl start firewalld
|
||||
```
|
||||
|
||||
### 关闭防火墙
|
||||
|
||||
```bash
|
||||
```sh
|
||||
systemctl stop firewalld
|
||||
```
|
||||
|
||||
### 查看开放的端口列表
|
||||
|
||||
```bash
|
||||
```sh
|
||||
firewall-cmd --zone=public --list-ports
|
||||
```
|
||||
|
||||
### 查看防火墙某个端口是否开放
|
||||
|
||||
```bash
|
||||
```sh
|
||||
firewall-cmd --query-port=端口号/tcp
|
||||
```
|
||||
|
||||
### 开放端口
|
||||
|
||||
```bash
|
||||
```sh
|
||||
# 开放某个端口
|
||||
firewall-cmd --zone=public --add-port=端口号/tcp --permanent
|
||||
# 开放指定端口范围
|
||||
@@ -114,12 +122,12 @@ firewall-cmd --zone=public --add-port=端口号起-端口号止/tcp --permanent
|
||||
|
||||
### 关闭端口
|
||||
|
||||
```bash
|
||||
```sh
|
||||
firewall-cmd --zone=public --remove-port=端口号/tcp --permanent
|
||||
```
|
||||
|
||||
### 重启防火墙(防火墙配置立即生效)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
firewall-cmd --reload
|
||||
```
|
@@ -40,7 +40,7 @@ tags:
|
||||
|
||||
1. 克隆后端项目仓库到本地(笔者没有在 git bash 中操作,而是在 cmd 中进行的)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git clone https://gitee.com/Charles7c/eladminx.git
|
||||
cd eladminx
|
||||
```
|
||||
@@ -49,7 +49,7 @@ tags:
|
||||
|
||||
2. 将前端仓库作为后端仓库的远程仓库,起别名为 frontend(这个随便起)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git remote add -f frontend https://gitee.com/Charles7c/eladminx-web.git
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ tags:
|
||||
|
||||
3. 将前端仓库的 master 分支(自己选择哪个分支)合并到后端仓库
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git merge --strategy ours --no-commit frontend/master
|
||||
```
|
||||
|
||||
@@ -71,7 +71,7 @@ tags:
|
||||
|
||||
这是因为后端仓库的本地分支历史记录和前端仓库的历史记录不匹配,人家 Git 怀疑你是不是合并错了,但咱们知道就是要合并,写个声明 “表明出事儿与人家无关”就可以了。
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git merge --strategy ours --allow-unrelated-histories --no-commit frontend/master
|
||||
```
|
||||
|
||||
@@ -79,20 +79,20 @@ tags:
|
||||
|
||||
4. 将前端仓库的 master 分支内容放到在后端仓库内刚建好的 eladminx-web 文件夹中
|
||||
|
||||
```bash
|
||||
```sh
|
||||
mkdir eladminx-web
|
||||
git read-tree --prefix=eladminx-web/ -u frontend/master
|
||||
```
|
||||
|
||||
5. 提交刚才的修改(毕竟你刚才又合并又创建文件夹的,肯定要提交修改啊)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git commit -m "迁移前端项目仓库,与后端项目仓库合并"
|
||||
```
|
||||
|
||||
6. 最后将本地的修改强制推送到远程仓库即可
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git push --force
|
||||
```
|
||||
|
||||
|
@@ -22,13 +22,13 @@ tags:
|
||||
|
||||
1. 修改最后一次提交的作者和邮箱信息
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git commit --amend --author="Charles7c <charles7c@126.com>"
|
||||
```
|
||||
|
||||
2. 最后将本地的修改强制推送到远程仓库即可(如果你没推送到远程仓库,这步就不需要执行了)
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git push --force
|
||||
```
|
||||
|
||||
@@ -36,7 +36,7 @@ tags:
|
||||
|
||||
**C:** 另外说一下,如果你要修改最后一次提交记录的 commit message,执行下面的命令就可以了。
|
||||
|
||||
```bash
|
||||
```sh
|
||||
git commit --amend -m "要修改为的提交信息"
|
||||
```
|
||||
|
||||
|
@@ -22,7 +22,7 @@ tags:
|
||||
|
||||
2. 复制下方脚本内容到脚本文件中,然后编辑替换好错误邮箱、正确作者和邮箱(如果是在 cmd 中执行,#!/bin/sh 就替换为 #!/bin/bat)
|
||||
|
||||
```shell
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
git filter-branch --env-filter '
|
||||
|
@@ -29,7 +29,7 @@ tags:
|
||||
|
||||
我们先一起回忆下全局配置用户名和邮箱的方法,在任意 Git 仓库里进行如下配置即可:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
# 全局配置用户名
|
||||
git config --global user.name "Charles7c"
|
||||
# 全局配置邮箱
|
||||
@@ -40,7 +40,7 @@ git config --global user.email "charles7c@126.com"
|
||||
|
||||
局部配置的方法也是非常简单,首先进入指定的 Git 仓库,然后进行如下配置即可:
|
||||
|
||||
```shell
|
||||
```sh
|
||||
# 进入指定 Git 仓库
|
||||
cd HelloWorld
|
||||
# 局部配置用户名
|
||||
@@ -55,7 +55,7 @@ git config user.email "charles7c@126.com"
|
||||
当然了,你也可以去其他没进行局部配置的仓库看看,看看它们的用户名和邮箱有没有受到影响。
|
||||
:::
|
||||
|
||||
```shell
|
||||
```sh
|
||||
# 查看所在 Git 仓库配置的用户名
|
||||
git config user.name
|
||||
# 查看所在 Git 仓库配置的邮箱
|
||||
|
77
docs/categories/fragments/2022/08/29/内网CentOS服务器设置网络代理.md
Normal file
77
docs/categories/fragments/2022/08/29/内网CentOS服务器设置网络代理.md
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
title: 内网CentOS服务器设置网络代理
|
||||
author: 查尔斯
|
||||
date: 2022/08/29 20:53
|
||||
categories:
|
||||
- 杂碎逆袭史
|
||||
tags:
|
||||
- Linux
|
||||
- 网络代理
|
||||
---
|
||||
|
||||
# 内网CentOS服务器设置网络代理
|
||||
|
||||
**C:** 今天在网管那新申请了一台服务器,打算用来做测试环境。但是内网服务器没有网络,所以需要设置一下网络代理才能满足上网要求。
|
||||
|
||||
<!-- more -->
|
||||
|
||||
## 设置http/https代理
|
||||
|
||||
1. 修改 profile 文件
|
||||
|
||||
```sh
|
||||
vi /etc/profile
|
||||
```
|
||||
|
||||
2. 在 profile 文件末尾,追加下方配置内容
|
||||
|
||||
```sh
|
||||
# 注意:这台机器必须能够访问配置的代理服务器
|
||||
export http_proxy=http://你的代理服务器地址:你的代理服务器端口号
|
||||
export https_proxy=http://你的代理服务器地址:你的代理服务器端口号
|
||||
```
|
||||
|
||||
如果你的代理服务器需要登录,那么只需要如下写法即可:
|
||||
|
||||
```sh
|
||||
# 注意:这台机器必须能够访问配置的代理服务器
|
||||
export http_proxy=http://用户名:密码@你的代理服务器地址:你的代理服务器端口号
|
||||
export https_proxy=http://用户名:密码@你的代理服务器地址:你的代理服务器端口号
|
||||
```
|
||||
|
||||
|
||||
## 设置yum代理
|
||||
|
||||
因为安装一些环境的时候还需要用到 yum,所以给 yum 也配置一下代理。
|
||||
|
||||
1. 修改 yum.conf 文件
|
||||
|
||||
```sh
|
||||
vi /etc/yum.conf
|
||||
```
|
||||
|
||||
2. 在 yum.conf 文件末尾,追加下方配置内容
|
||||
|
||||
```sh
|
||||
proxy=http://你的代理服务器地址:你的代理服务器端口号
|
||||
```
|
||||
|
||||
当然了,如果你的代理服务器需要登录,写法也和设置 http/https 代理时一样。
|
||||
|
||||
都设置完之后,执行 `reboot` 重启服务器,让配置生效即可。
|
||||
|
||||
## 检测是否可以上网
|
||||
|
||||
重启后,为了确认配置是否成功,执行 `curl` 来测试一下。
|
||||
|
||||
```sh
|
||||
curl www.baidu.com
|
||||
```
|
||||
|
||||
很明显,看到下面的返回就知道配置成功了,如期返回了百度的页面内容。
|
||||
|
||||
```
|
||||
<!DOCTYPE html>
|
||||
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>使用百度前必读</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号 <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>
|
||||
```
|
||||
|
Reference in New Issue
Block a user