Press "Enter" to skip to content

日期: 2020 年 8 月 25 日

CentOS8下安装Go环境安装

Go 语言支持以下系统:

  • Linux
  • FreeBSD
  • Mac OS X(也称为 Darwin)
  • Window

先打开网址:https://golang.google.cn/dl/ 下载需要的版本,Win,Mac,Linux自行选择自己的环境 ,这里只介绍Linux环境的配置。

[root@kiccleaf ~]# wget https://golang.google.cn/dl/go1.15.linux-amd64.tar.gz
[root@kiccleaf ~]# tar zxvf go1.15.linux-amd64.tar.gz
[root@kiccleaf ~]# mv go /usr/local/
[root@kiccleaf ~]# vim /etc/profile
在文件底部增加:
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
保存退出后
[root@kiccleaf ~]# source /etc/profile
[root@kiccleaf ~]# go version
go version go1.15 linux/amd64
显示go环境安装成功,是不是有点太简单了?
来吧,第一个go程序
[root@kiccleaf ~]# vim helloword.go

helloword.go内容:

package main
import "fmt"
func main(){
   fmt.Printf("Hello Word!\n");
}
[root@kiccleaf ~]# go build helloword.go 
[root@kiccleaf ~]# ./helloword 
Hello Word!
[root@kiccleaf ~]# du -sh helloword
2.0M	helloword
编译好的文件还是有点大的,简单的一个Hello Word!需要2M的大小。
Leave a Comment

CentOS8安装PHP8

最新系统上来了这大半年都没有时间安装用用,php-8.0.0beta2 也发布出来了,先记录一下,CentOS8安装选择最小安装(跟原来安装差不多没变化),所以安装速度很快,因为是最小安装所以有些工具没有,能少则少的原则

简单说一下yum源修改

先安装wget工具:

yum install -y wget
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

或者用

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
yum makecache 生成缓存

系统缺少命令ifconfig,netstat,whois等命令需要安装net-tools.x86_64,另外习惯使用vim编辑器,所以每次都会安装,常用的screen也是要安装的,但在CentOS8系统下直接yum install screen是安装失败的

[root@kiccleaf ~]# yum install screen
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Last metadata expiration check: 0:01:32 ago on Tue 25 Aug 2020 02:16:39 PM CST.
No match for argument: screen
Error: Unable to find a match: screen
办法总是有的,先安装epel-release
[root@kiccleaf ~]# yum install -y epel-release
Installed:
  epel-release-8-8.el8.noarch                                                                                                                                                                                                               

Complete!
[root@kiccleaf ~]# yum install -y screen
Installed:
  screen-4.6.2-10.el8.x86_64                                                                                                                                                                                                                

Complete!
[root@kiccleaf ~]# 
安装成功了!测试一下
[root@kiccleaf ~]# screen -S kiccleaf
新的窗体里面了
[root@kiccleaf ~]#
Ctrl+ad  临时退出窗体
[detached from 35676.kiccleaf]

重新进入刚才的窗体
[root@kiccleaf ~]# screen -r kiccleaf
退出窗体
[root@kiccleaf ~]# exit
exit
[screen is terminating]
到此完美使用screen工具了。
接下去安装vim和网络命令
[root@kiccleaf ~]# yum install -y net-tools.x86_64 vim 
来看一下系统的版本吧
[root@kiccleaf ~]# cat /etc/redhat-release 
CentOS Linux release 8.2.2004 (Core) 
[root@kiccleaf ~]# 

先下载PHP8源码包,下载网址:https://downloads.php.net/~pollita/

[root@kiccleaf ]# wget https://downloads.php.net/~pollita/php-8.0.0beta2.tar.gz
[root@kiccleaf ]# tar zxvf php-8.0.0beta2.tar.gz
[root@kiccleaf ]# cd php-8.0.0beta2
根据自己的需求进行配置安装相应的扩展
[root@kiccleaf php-8.0.0beta2]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-sockets --with-zip --enable-calendar --enable-bcmath --enable-mbstring --with-zlib --with-iconv=/usr/local/libiconv --enable-gd --enable-mbstring --with-curl --with-freetype --disable-ipv6 --disable-debug --with-openssl --enable-intl --enable-opcache

[root@kiccleaf php-8.0.0beta2]# make 
[root@kiccleaf php-8.0.0beta2]# make install

在执行中可能会遇到一些问题,这里简单说明一下:

1. configure: error: iconv does not support errno

[root@kiccleaf ]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[root@kiccleaf ]# tar zxvf libiconv-1.15.tar.gz
[root@kiccleaf libiconv-1.15]#  cd libiconv-1.15
[root@kiccleaf libiconv-1.15]# ./configure --prefix=/usr/local/libiconv
[root@kiccleaf libiconv-1.15]#  make 
[root@kiccleaf libiconv-1.15]#  make install
安装好PHP8后配置进行启动
[root@kiccleaf php-8.0.0beta2]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@kiccleaf php-8.0.0beta2]# chmod a+x /etc/init.d/php-fpm
[root@kiccleaf php-8.0.0beta2]# service php-fpm start
[root@kiccleaf php-8.0.0beta2]# php -v
PHP 8.0.0beta2 (cli) (built: Aug 24 2020 13:47:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
Leave a Comment

CentOS7/8和FreeBSD-12修改主机名字

默认情况下Linux主机的名称是localhost如:

[root@localhost ~]# hostname
localhost.localdomain

修改如下:

 [root@localhost ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

把中间的localhost.localdomain修改成自己的名称:kiccleaf

127.0.0.1 localhost kiccleaf localhost4 localhost4.localdomain4
::1 localhost kiccleaf localhost6 localhost6.localdomain6

[root@localhost ~]# vim /etc/hostname
把localhost名称修改成自己的名称:kiccleaf

重启一下系统

[root@localhost ~]# reboot
Connecting to *.*.*.*:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].

          Welcome to CentOS 8
  _     _            _                 ___
 | |   (_)          | |               / __)
 | |  _ _  ____ ____| | _____ _____ _| |__
 | |_/ ) |/ ___) ___) || ___ (____ (_   __)
 |  _ (| ( (__( (___| || ____/ ___ | | |
 |_| \_)_|\____)____)\_)_____)_____| |_|

Last login: Tue Aug 25 11:57:55 2020 from *.*.*.*
[root@kiccleaf ~]# hostname
kiccleaf

FreeBSD修改名称比较简单

root@localhost:~ # vim /etc/rc.conf
hostname="kiccleaf"
root@localhost:~ # reboot

#重启后连接显示
Connecting to *.*.*.*:22...
Connection established.
To escape to local shell, press Ctrl+Alt+].

Last login: Mon Aug 24 18:06:00 2020 from *.*.*.*
FreeBSD 12.1-RELEASE r354233 GENERIC 
  
      Welcome to FreeBSD!
   _     _            _                 ___
  | |   (_)          | |               / __)
  | |  _ _  ____ ____| | _____ _____ _| |__
  | |_/ ) |/ ___) ___) || ___ (____ (_   __)
  |  _ (| ( (__( (___| || ____/ ___ | | |
  |_| \_)_|\____)____)\_)_____)_____| |_|

root@kiccleaf:~ # uname -a
FreeBSD kiccleaf 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC  amd64

Leave a Comment