Press "Enter" to skip to content

平淡人生 Posts

CentOS8安装PHP8

热度 162 度

最新系统上来了这大半年都没有时间安装用用,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修改主机名字

热度 66 度

默认情况下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

Centos7安装php7.4.9+redis扩展

热度 139 度

本文只讲php的编译及Redis扩展的安装,其他nginx的安装什么都相同方式无非就是配置需要修改一下。

php7.4.9安装包下载:https://www.php.net/downloads.php#v7.4.9

我下载了:https://www.php.net/distributions/php-7.4.9.tar.bz2

解压 tar jzvf php-7.4.9.tar.bz2,并打开php-7.4.9目录,需要安装的扩展自行增减,然后进行编译:

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-zip --disable-fileinfo
进行make时会提示错误:
collect2: error: ld returned 1 exit status
make: *** [sapi/cli/php] Error 1

需要:make ZEND_EXTRA_LIBS=’-liconv’ 进行编译操作

等编译后make install安装完成!

把php-fpm做成系统启动,先复制 php-7.4.9目录下./sapi/fpm/init.d.php-fpm至/etc/init.d/目录下

cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

复制完,执行service php-fpm start 会提示错误:env: /etc/init.d/php-fpm: Permission denied,因为 init.d目录下需要给相应的权限才可执行:

chmod a+x /etc/init.d/php-fpm

执行service php-fpm start 提示:Starting php-fpm done 说明启动成功!

然后第二步安装Redis扩展,下载地址:https://pecl.php.net/package/redis 选择自己适合的扩展,我选择了最新的Redis5.3.1版本

wget https://pecl.php.net/get/redis-5.3.1.tgz
tar zxvf redis-5.3.1.tgz
cd redis-5.3.1
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install

–with-php-config=/usr/local/php/bin/php-config 根据自己安装的位置找到php-config

编辑php.ini文件

vim /usr/local/php/etc/php.ini

找到extension区域,增加:extension=redis.so,然后保存退出

重启php进程 service php-fpm restart

查看php是否已经安装了redis模块:

[root@localhost php-7.4.9]# php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
filter
gettext
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
redis
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvsem
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

[Zend Modules]

这里特别注意:–with-config-file-path=/usr/local/php/etc编译PHP是指定目录 php.ini文件,如果非此目录的php.ini文件增加扩展,重启是不会加载扩展。新手要特别注意!!!

写一个php文件:phpinfo.php

<?php
  phpinfo();
?>

找到此配置信息项:

Configuration File (php.ini) Path/usr/local/php/etc
Loaded Configuration File/usr/local/php/etc/php.ini

转载请注明出处!

Leave a Comment

个性化Linux/FreeBSD字符界面,登录输出显示信息

热度 77 度

很多年以前写过Linux登录时输出个性信息,被各大平台及个人博客转载,遗憾的是他们从来没有写上原文从哪里转载过来,我个人支持大家相互学习和转载,但请转载注明一下出处可以吗?怎么说也是我的小小劳动成果。

Linux及FreeBSD下编辑/etc/motd

vi /etc/motd

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

FreeBSD就添加相应的提示信息(清空原FreeBSD下/etc/motd文件自带的信息,会比较多,全清掉即可)

FreeBSD 12.1-RELEASE r354233 GENERIC
  
          Welcome to FreeBSD!
   _     _            _                 ___
  | |   (_)          | |               / __)
  | |  _ _  ____ ____| | _____ _____ _| |__
  | |_/ ) |/ ___) ___) || ___ (____ (_   __)
  |  _ (| ( (__( (___| || ____/ ___ | | |
  |_| \_)_|\____)____)\_)_____)_____| |_|

欢迎转载,请注明出处,谢谢!

原来《个性化Linux字符界面,登录输出显示信息》中有颜色更漂亮,但是针对使用WinSCP软件SFTP登录时会有错误提示:WinSCP登陆服务器提示收到了太大的SFTP包 支持的最大包大小1024000B,总有得失,看个人喜欢。

Leave a Comment

xshell无法在FreeBSD系统下vim中复制粘贴解决方法

热度 95 度

ssh xshell 连接FreeBSD系统下使用编辑器vim中无法用 ctrl+insert 实现复制粘贴,可以用以下方法来解决。

编辑文件(默认没有这个文件)
vim ~/.vimrc
或者你当前登录如果是root用户的话可以vim /root/.vimrc

set mouse=c
syntax on

说明:
第一行:设置成命令行模式,设置完成后代码高亮会消失;
第二行:设置代码高亮。

顺道记录一下Xshell中的复制粘贴和我们常用的不同Ctrl+v,Ctrl+C,Xshell中用的是Ctrl+Insert是复制,Shift+Insert 粘贴,改一下菜单就可统一成我们自己习惯的方式了。

第一步:打开“工具”–“选项”

再打开“编辑”后弹出以下菜单:

“新建”一个组合键,Ctrl+V,在编辑窗体中选择类型和操作后确定

新建Ctrl+V,Ctrl+C操作好后确定即可使用了。非常方便

写在最后的话,Ctrl+C不建议用这个快捷键,因为Linux或是FreeBSD系统下有时需要用Ctrl+C进行终止程序,所以可以修改成自己喜欢的快捷键如:Ctrl+Shift+C

Leave a Comment

Linux md5sum校验文件是否被篡改

热度 94 度

因为有些平台日常不会作更新操作,担心文件被非法修改自己又不知道,所以采用linux提供的简单命令来实现文件校验。

先把目录中的所有文件进行MD5,sort参数是排序后存放在md5.txt文件中,这个文件保存好,因为这是你历史的文件的md5,如果目录中某个文件被修改,在校验中就被找出来。

find /data -type f -print0 | xargs -0 md5sum | sort >md5.txt

校验文件是否被修改过,不显示正常的文件采用grep -v OK

root@kiccleaf data]# md5sum -c md5.txt | grep -v OK
/data/g.sh: FAILED
md5sum: WARNING: 1 computed checksum did NOT match

Comments closed

Linux中的chkconfig增加自己想要启动项

热度 258 度

总有些需要自己配置启动项的,简单记录一下过程

#先写一个自己需要执行的软件或是其他要执行的事项,这里就拿同步系统时间作为例子
[root@localhost ~]# vim /root/syncDate.sh
#!/bin/bash
/usr/sbin/ntpdate cn.pool.ntp.org>/root/times.log
[root@localhost ~]# chmod +x /root/syncDate.sh

#开始写启动项文件kiccleaf
[root@localhost ~]# vim /etc/init.d/kiccleaf
#!/bin/bash
# chkconfig: 3 88 88
/bin/bash /root/syncDate.sh &>/dev/null 2&>/dev/null

注意:# chkconfig: 3 88 88 这一行很重要,如果不添加,
执行chkconfig –add kiccleaf 会提示失败

[root@localhost ~]# chkconfig --add kiccleaf
service kiccleaf does not support chkconfig
#以上是失败提醒,未增加# chkconfig: 3 88 88

#增加可执行权限
[root@localhost ~]# chmod +x /etc/init.d/kiccleaf

#添加到chkconfig,开机自启动
[root@localhost ~]# chkconfig --add kiccleaf
[root@localhost ~]# chkconfig --list kiccleaf

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

kiccleaf        0:off   1:off   2:off   3:on    4:off   5:off   6:off
#重启系统,查看结果

[root@localhost ~]# cat /root/times.log
12 Jun 11:38:34 ntpdate[10221]: step time server 203.107.6.88 offset -28799.359688 sec
操作成功

#关闭开机启动

[root@localhost ~]# chkconfig kiccleaf off
[root@localhost ~]# chkconfig --list kiccleaf
kiccleaf        0:off   1:off   2:off   3:off   4:off   5:off   6:off

#从chkconfig管理中删除kiccleaf
[root@localhost ~]# chkconfig --del kiccleaf
#查看列表中是否还存在kiccleaf启动项,结果已经没有
[root@localhost ~]# chkconfig --list kiccleaf
service kiccleaf supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add kiccleaf')

关于chkconfig更多内容,可以参考:Linux下chkconfig命令详解

Comments closed

linux中rc.local设置开机自启没有生效解决方案

热度 230 度

经常在一些小细节方面卡壳,先查看一下文件是否有执行属性

[root@localhost ~]# ll /etc/rc.d/rc.local
-rw-r--r--  1 root root 507 Jun 12 11:01 /etc/rc.d/rc.local

#上面可以看出没有可执行权限,添加以下可执行权限即可
[root@localhost ~]# chmod +x  /etc/rc.d/rc.local
[root@localhost ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 507 Jun 12 11:01 /etc/rc.d/rc.local
#执行后,查看已经增加了可执行权限

想在系统启动后执行的命令可以添加到/etc/rc.d/rc.local文件
比如启动时同步系统时间

#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
#同步系统时间
/usr/sbin/ntpdate cn.pool.ntp.org
Comments closed

FreeBSD升级Nginx

热度 1,202 度

最新nginx版本解决了SSL漏洞,所以需要升级一下nginx版本至最新,以下是FreeBSD下用pkg升级的方法。

root@kiccleaf:~ # nginx -v
nginx version: nginx/1.12.0
root@kiccleaf:~ # pkg upgrade nginx
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    944 B   0.9kB/s    00:01    
Fetching packagesite.txz: 100%    6 MiB  95.5kB/s    01:11    
Processing entries: 100%
FreeBSD repository update completed. 33333 packages processed.
The following 2 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
	nginx: 1.12.0_1,2 -> 1.14.0_13,2
	pcre: 8.40_1 -> 8.42

The process will require 178 KiB more space.
2 MiB to be downloaded.

Proceed with this action? [y/N]: y
Fetching nginx-1.14.0_13,2.txz: 100%  416 KiB 425.5kB/s    00:01    
Fetching pcre-8.42.txz: 100%    1 MiB   1.2MB/s    00:01    
Checking integrity... done (0 conflicting)
[1/2] Upgrading pcre from 8.40_1 to 8.42...
[1/2] Extracting pcre-8.42: 100%
[2/2] Upgrading nginx from 1.12.0_1,2 to 1.14.0_13,2...
You may need to manually remove /usr/local/etc/nginx/nginx.conf if it is no longer needed.
===> Creating groups.
Using existing group 'www'.
===> Creating users
Using existing user 'www'.
[2/2] Extracting nginx-1.14.0_13,2: 100%
Message from nginx-1.14.0_13,2:
===================================================================
Recent version of the NGINX introduces dynamic modules support.  In
FreeBSD ports tree this feature was enabled by default with the DSO
knob.  Several vendor's and third-party modules have been converted
to dynamic modules.  Unset the DSO knob builds an NGINX without
dynamic modules support.

To load a module at runtime, include the new `load_module'
directive in the main context, specifying the path to the shared
object file for the module, enclosed in quotation marks.  When you
reload the configuration or restart NGINX, the module is loaded in.
It is possible to specify a path relative to the source directory,
or a full path, please see
https://www.nginx.com/blog/dynamic-modules-nginx-1-9-11/ and
http://nginx.org/en/docs/ngx_core_module.html#load_module for
details.

Default path for the NGINX dynamic modules is

/usr/local/libexec/nginx.
===================================================================
root@kiccleaf:~ # nginx -v
nginx version: nginx/1.14.0
Comments closed

FreeBSD 升级PHP版本

热度 3,035 度

使用到的命令
pkg update 更新下软件库的信息,这样可以知道软件库中个套件的最新版本。
pkg upgrade 是升级你安装的套件
pkg info 显示软件包信息

第一步升级PHP版本

root@kiccleaf:~ # php -v  #查看升级前PHP版本
PHP 7.1.4 (cli) (built: Nov 25 2017 01:17:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.4, Copyright (c) 1999-2017, by Zend Technologies

root@kiccleaf:~ # pkg upgrade php71
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
	php71: 7.1.4 -> 7.1.12
	pcre: 8.37_4 -> 8.40_1

The process will require 84 KiB more space.
3 MiB to be downloaded.

Proceed with this action? [y/N]: y   #同意更新
Fetching php71-7.1.12.txz: 100%    2 MiB 103.2kB/s    00:21    
Fetching pcre-8.40_1.txz: 100%    1 MiB 165.7kB/s    00:07    
Checking integrity... done (0 conflicting)
[1/2] Upgrading pcre from 8.37_4 to 8.40_1...
[1/2] Extracting pcre-8.40_1: 100%
[2/2] Upgrading php71 from 7.1.4 to 7.1.12...
You may need to manually remove /usr/local/etc/php-fpm.d/www.conf if it is no longer needed.
[2/2] Extracting php71-7.1.12: 100%
root@kiccleaf:~ # php -v  #查看升级后版本
PHP 7.1.12 (cli) (built: Nov 25 2017 01:17:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.4, Copyright (c) 1999-2017, by Zend Technologies

第二步升级下PHP扩展

pkg upgrade -y php71-ctype php71-dom php71-filter php71-hash php71-iconv php71-json php71-mysqli php71-opcache php71-pdo php71-pdo_mysql php71-pdo_sqlite php71-phar php71-posix php71-session php71-simplexml php71-sqlite3 php71-tokenizer php71-xml php71-xmlreader php71-xmlwriter

Comments closed