及配置 直接执行安装命令即可:
#yum -y install wget
#yum -y install setup
#yum -y install perl
加载ifconfig
yum install net-tools
及配置 直接执行安装命令即可:
#yum -y install wget
#yum -y install setup
#yum -y install perl
加载ifconfig
yum install net-tools
今天在下载chromiumos 代码的时候,按照google官网的提示步骤下载的时候,
提示Unable to find remote helper for ‘http’,发现原来是git安装不完全
的问题造成的。如果是centos,用下面命令安装即可
frp 是一个高性能的反向代理应用,可以轻松地进行内网穿透,对外网提供服务,支持 TCP、UDP、HTTP、HTTPS 等协议类型,并且 web 服务支持根据域名进行路由转发。
Github: https://github.com/fatedier/frp
当然frp作者已经提供多达20种已编译好的各种版本可以供大家使用,几乎不需要自己编译。
但是有时候我们需要自定义一些内容,这时候就需要自行编译了。
1、安装依赖
#Ubuntu
sudo apt-get install bison ed gawk gcc libc6-dev make
#CentOS
sudo yum install gcc
2、下载go支持包
各版本的下载地址 https://www.golangtc.com/static/go/,我使用的是当前最新的1.9.2版本
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
3、解压go包
sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
4、添加环境变量和go工作区
vim /etc/profile
在文件的底部添加以下两行:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/usr/local/gopath
:wq
保存退出后,重新加载环境变量
source /etc/profile
至此,go环境搭建完毕。
直接运行以下命令
go get github.com/fatedier/frp
cd /usr/local/gopath/src/github.com/fatedier/frp/
make
make 编译完成后,frp里会多出一个bin目录,放着frpc和frps,对应客户端和服务端的可执行文件。服务端上只需要用到 frps,可以删掉 frpc,客户端则相反。
404页面在源码路径utils/vhost/resource.go文件里,
更改部分如图
404源码示例1
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>404 找不到此页面/(ㄒoㄒ)/~~</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<style>*{padding:0;margin:0}a{text-decoration:none}.notfoud-container .img-404{height:155px;background:url(https://www.ituku.me/images/0c87.png) center center no-repeat;-webkit-background-size:150px auto;margin-top:40px;margin-bottom:20px}.notfoud-container .notfound-p{line-height:22px;font-size:17px;padding-bottom:15px;border-bottom:1px solid #f6f6f6;text-align:center;color:#262b31}.notfoud-container .notfound-reason{color:#9ca4ac;font-size:13px;line-height:13px;text-align:left;width:210px;margin:0 auto}.notfoud-container .notfound-reason p{margin-top:13px}.notfoud-container .notfound-reason ul li{margin-top:10px;margin-left:36px}.notfoud-container .notfound-btn-container{margin:40px auto 0;text-align:center}.notfoud-container .notfound-btn-container .notfound-btn{display:inline-block;border:1px solid #ebedef;background-color:#239bf0;color:#fff;font-size:15px;border-radius:5px;text-align:center;padding:10px;line-height:16px;white-space:nowrap}</style>
</head>
<body>
<div class="notfoud-container">
<div class="img-404">
</div>
<p class="notfound-p">哎呀迷路了...</p>
<div class="notfound-reason">
<p>可能的原因:</p>
<ul>
<li>frpc没有启动成功</li>
<li>域名不正确</li>
<li>内网端不存在该页面</li>
<li>我们的服务器被外星人劫持了</li>
</ul>
</div>
<div class="notfound-reason">
<p align="center"><a href=http://freenat.win/>免费frp内网穿透服务</a>
</div>
</div>
</body>
404源码示例2
<head>
<meta charset="UTF-8" http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>404-找不到此页面/(ㄒoㄒ)/~~</title>
<style type="text/css">
.head404{ width:196px; height:196px; margin:50px auto 0 auto; background:url(https://www.ituku.me/images/0zHK.png) no-repeat; }
.txtbg404{ width:499px; height:169px; margin:10px auto 0 auto; background:url(https://www.ituku.me/images/0DQE.png) no-repeat;}
.txtbg404 .txtbox{ width:390px; position:relative; top:30px; left:60px;color:#eee; font-size:13px;}
.txtbg404 .txtbox p {margin:5px 0; line-height:18px;}
.txtbg404 .txtbox .paddingbox { padding-top:15px;}
.txtbg404 .txtbox p a { color:#eee; text-decoration:none;}
.txtbg404 .txtbox p a:hover { color:#FC9D1D; text-decoration:underline;}
</style>
</head>
<body bgcolor="#494949">
<div class="head404"></div>
<div class="txtbg404">
<div class="txtbox">
<p>对不起,您请求的页面不存在、或已被删除、或暂时不可用</p>
<p class="paddingbox">可能的原因:</p>
<p>1、frpc没有启动成功;</p>
<p>2、域名不正确;</p>
<p>3、内网端不存在该网页;</p>
<p>4、frp服务器被外星人劫持了。</p>
<p> </p>
<p align="center"><a href=http://freenat.win/>免费frp内网穿透服务</a> Powered by <a href="http://agint.me/">SWORD'S BLOG</a></p>
</div>
</div>
</body>
你可以自行更改后再编译,就可以了
1.下载安装包,地址为:https://golang.org/dl/ , 我的操作系统为centos6,我下载的是:go1.9.2.linux-amd64.tar.gz
cd /tools
wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
tar -C /usr/local -xzf /usr/local/go1.9.2.linux-amd64.tar.gz
2.写入环境变量
如果 /root/go 文件夹不存在,则新建该文件夹
vim /etc/profile ,在最后另起新行添加下面的环境变量
export GOROOT=/usr/local/go
export GOPATH=/root/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
让环境变量生效:
source /etc/profile
这样,go安装就完成了。
前言 frp 是一个高性能的反向代理应用,可以轻松地进行内网穿透,对外网提供服务,支持 TCP、UDP、HTTP、HTTPS 等协议类型,并且 web 服务支持根据域名进行路由转发。 当然frp作者已经提供多达20种已编译好的各种版本可以供大家使用,几乎不需要自己编译。 但是有时候我们需要自定义一些内容,这时候就需要自行编译了。
搭建GO环境
1、安装依赖
#Ubuntu sudo apt-get install bison ed gawk gcc libc6-dev make
#CentOS sudo yum install gcc
2、下载go支持包 各版本的下载地址 https://www.golangtc.com/static/go/,我使用的是当前最新的1.9.2版本
wget https://www.golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
3、解压go包 sudo tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
4、添加环境变量和go工作区
vim /etc/profile
在文件的底部添加以下两行:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=/usr/local/gopath
:wq 保存退出后,
重新加载环境变量
source /etc/profile
至此,go环境搭建完毕。
5. 下载编译frp 直接运行以下命令 go get github.com/fatedier/frp
cd /usr/local/gopath/src/github.com/fatedier/frp/ make make
编译完成后,frp里会多出一个bin目录,放着frpc和frps,对应客户端和服务端的可执行文件。服务端上只需要用到 frps,可以删掉 frpc,客户端则相反。
6.修改404页面
404页面在源码路径
utils/vhost/resource.go
文件里,你可以自行更改后编译
7. 压缩Golang 编译出的可执行文件70%大小
工具 upx
#Ubuntu sudo apt-get install upx
upx frps
例如:我编译的约 11M. 压缩后只有 3.4M. 详细教程不在说明
8.全平台编译
go支持跨平台编译,平时我们在mac或者windows上面开发,部署服务器的时候需要编译成linux的可执行文件,可以使用命令行进行跨平台编译,但是每次敲命令有点麻烦,gogland简单配置一下也可以实现同样的功能。
打开configuration:
添加Go Application,在environment里面添 GOOS=linux;GOARCH=amd64
$GOOS $GOARCH
android arm
darwin 386
darwin amd64
darwin arm
darwin arm64
dragonfly amd64
freebsd 386
freebsd amd64
freebsd arm
linux 386
linux amd64
linux arm
linux arm64
linux ppc64
linux ppc64le
linux mips
linux mipsle
linux mips64
linux mips64le
netbsd 386
netbsd amd64
netbsd arm
openbsd 386
openbsd amd64
openbsd arm
plan9 386
plan9 amd64
solaris amd64
windows 386
windows amd64
———————
作者:zhaobisheng1
来源:CSDN
原文:https://blog.csdn.net/zhaobisheng1/article/details/81265310
版权声明:本文为博主原创文章,转载请附上博文链接!
然后运行就能编译出在linux下面运行的可执行文件。
参考文章:
有些人安装的linux的系统默认防火墙不是iptables,而是firewall,那就得使用以下方式关闭防火墙了。
>>>关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
>>>开启端口
firewall-cmd –zone=public –add-port=80/tcp –permanent
命令含义
–zone #作用域
–add-port=80/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
>>>重启防火墙
firewall-cmd –reload
其他常用命令:
firewall-cmd –state ##查看防火墙状态,是否是running
firewall-cmd –reload ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd –get-zones ##列出支持的zone
firewall-cmd –get-services ##列出支持的服务,在列表中的服务是放行的
firewall-cmd –query-service ftp ##查看ftp服务是否支持,返回yes或者no
firewall-cmd –add-service=ftp ##临时开放ftp服务
firewall-cmd –add-service=ftp –permanent ##永久开放ftp服务
firewall-cmd –remove-service=ftp –permanent ##永久移除ftp服务
firewall-cmd –add-port=80/tcp –permanent ##永久添加80端口
iptables -L -n ##查看规则,这个命令是和iptables的相同的
man firewall-cmd ##查看帮助
更多命令,使用 firewall-cmd –help 查看帮助文件
>>> CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下
1、直接关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、设置 iptables service
yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
centos7与之前的版本都不一样,修改主机名在/ect/hostname 和/ect/hosts 这两个文件控制
首先修改/etc/hostname
vi /etc/hostname
打开之后的内容是:
localhost.localdomain
把它修改成你想要的名字就可以,比如: niukou.com
保存退出
然后修改/etc/hosts文件
vi /etc/hosts
打开之后的内容是:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
然后你在里面加一行:
IP niukou.com
保存退出,然后重启机器,这时候你就可以通过hostname来访问这台机器的服务了
查看主机名:
uname -n //单独主机名
uname -a //详细信息
将centos7原主机名改为自己想要的那个样子
1、方法一使用hostnamectl命令
hostnamectl set-hostname 自己想要的名字
2、方法二:修改配置文件 /etc/hostname 保存退出
vi /etc/hostname
修改里面的名字成自己想要的那个,保存退出
一个img镜像写入工具
Phy写盘工具下载 physdiskwrite.exe v0.5.3 IMG写盘工具(容易误删电脑硬盘)
1、在windows下执行cmd命令
2、将physdiskwrite和img文件放在一个目录下,切换到该目录,执行physkiskwrite -u usb.img。
3、记住显示的信息,然后按CTRL+C终止操作。
4、将移动硬盘连接到电脑上,在命令行窗口,再次执行physkiskwrite -u usb.img,会看到多少的移动硬盘信息。
5、加入多出来的硬盘信息序号是1,则继续在dos下输入1回车然后,会问一次确认,输入y回车即可关键是要输入正确的移动硬盘的序号。
6、一般来说 0 是你系统的硬盘,1是移动硬盘。
7、如果你有多个硬盘,那移动硬盘应该是序号最大那个。
详细见图,注意这里文件放在D盘根目录( D:\ )
D:\physdiskwrite.exe -u usb.img ←这个“usb.img”按需要改成自己使用的IMG文件名!
Phy写盘工具下载 physdiskwrite.exe v0.5.3 IMG写盘工具(容易误删电脑硬盘) 下载-脚本之家
physdiskwrite.exe程序的相关参数:
Usage: physdiskwrite [-u] [-d driveno] <image-file>
-u remove 2 GB restriction (WARNING!)
-d specify drive number (0n) (no confirmation prompts!).