Press "Enter" to skip to content

分类: FreeBSD

FreeBSD 升级PHP版本

使用到的命令
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

linux 查看系统信息命令(比较全)

收集常用的Linux基本系统信息命令

 uname -a # 查看内核/操作系统/CPU信息
 head -n 1 /etc/issue # 查看操作系统版本
 cat /proc/cpuinfo # 查看CPU信息
 hostname # 查看计算机名
 lspci -tv # 列出所有PCI设备
 lsusb -tv # 列出所有USB设备
 lsmod # 列出加载的内核模块
 env # 查看环境变量资源
 free -m # 查看内存使用量和交换区使用量
 df -h # 查看各分区使用情况
 du -sh <目录名> # 查看指定目录的大小
 grep MemTotal /proc/meminfo # 查看内存总量
 grep MemFree /proc/meminfo # 查看空闲内存量
 uptime # 查看系统运行时间、用户数、负载
 cat /proc/loadavg # 查看系统负载磁盘和分区
 mount | column -t # 查看挂接的分区状态
 fdisk -l # 查看所有分区
 swapon -s # 查看所有交换分区
 hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)
 dmesg | grep IDE # 查看启动时IDE设备检测状况网络
 ifconfig # 查看所有网络接口的属性
 iptables -L # 查看防火墙设置
 route -n # 查看路由表
 netstat -lntp # 查看所有监听端口
 netstat -antp # 查看所有已经建立的连接
 netstat -s # 查看网络统计信息进程
 ps -ef # 查看所有进程
 top # 实时显示进程状态用户
 w # 查看活动用户
 id <用户名> # 查看指定用户信息
 last # 查看用户登录日志
 cut -d: -f1 /etc/passwd # 查看系统所有用户
 cut -d: -f1 /etc/group # 查看系统所有组
 crontab -l # 查看当前用户的计划任务服务
 chkconfig –list # 列出所有系统服务
 chkconfig –list | grep on # 列出所有启动的系统服务程序
 rpm -qa # 查看所有安装的软件包
Leave a Comment

FreeBSD下更改csh为bash后root无法登录解决办法

FreeBSD下为了判断一个进程是否存在,执行了chsh -s /bin/bash命令,不巧的是刚好断线,于是再次链接时没办法su root进去管理权限了。可悲的事情,只好请机房来帮忙操作。

chsh -s /bin/bash

查看/etc/passwd内容时发现

root:*:0:0:Charlie &:/root:/bin/bash
这一句被改了
原来是
root:*:0:0:Charlie &:/root:/bin/csh

利用cat命令查看/etc/passwd

kiccleaf# cat /etc/passwd
# $FreeBSD: src/etc/master.passwd,v 1.40.22.2.2.1 2012/03/03 06:15:13 kensmith Exp $
#
root:*:0:0:Charlie &:/root:/bin/bash

原来的内容是:

kiccleaf# cat /etc/passwd
# $FreeBSD: src/etc/master.passwd,v 1.40.22.2.2.1 2012/03/03 06:15:13 kensmith Exp $
#
root:*:0:0:Charlie &:/root:/bin/csh

结果FreeBSD的/bin/目录下并没有bash这个命令存在,于是登录时错误提示:

login:/bin/bash:No such file or directory

把root的shell改成了bash,而导致进不去系统了,可以通过以下几种方式解决:

系统启动时,选择“4”,进入“单用户”模式,输入“boot -s”进入单用户的提示符“#”,依次键入如下命令:

  fsck -p
  mount -u /
  mount -a -t ufs
  swapon -a
  chsh -s /bin/csh

然后就重启系统吧,这样就可以重新登录root管理帐号了。

Leave a Comment

FreeBSD修改root密码错误passwd: pam_chauthtok(): error in service module解决办法

在FreeBSD中修改帐号密码有时候会出现一些错误,针对passwd: pam_chauthtok(): error in service module这样的错误提示,简单整理了以下解决方案:
错误提示:

kiccleaf# passwd kiccleaf
Changing local password for kiccleaf
New Password:
Retype New Password:

/: write failed, filesystem is full
passwd: pam_chauthtok(): error in service module

修改方法:
1.把/etc/passwd 文件给所有权限
2.修改好密码
3.恢复文件相应权限

kiccleaf# ll /etc/passwd 
-rw-r--r--  1 root  wheel  1509 Apr 23 14:35 /etc/passwd

kiccleaf# chmod 777 /etc/passwd
kiccleaf# passwd kiccleaf
Changing local password for kiccleaf
New Password:
Retype New Password:

kiccleaf# chmod 644 /etc/passwd
Leave a Comment

Nginx HTTP Post Method: 405 Method not allowed解决方法

最近维护一台RedHat 5.4 X64系统,环境是Nginx,跑着一个论坛,需要向HTML页面提交POST数据,结果都被拦截下来了,显示错误:“nginx 405 Not Allowed”,是乎没有很好的解决办法,唯一能做的就是重新编译Nginx源码和编辑conf文件。
需要修改Nginx中的C源码文件位于 /nginx源码目录/src/http/modules/ngx_http_static_module.c ,找到如下代码:

    if (r->method == NGX_HTTP_POST) {
        return NGX_HTTP_NOT_ALLOWED;
    }


注释掉如下:

/*if (r->method == NGX_HTTP_POST) {
        return NGX_HTTP_NOT_ALLOWED;
    }
*/


然后再重新编译 make
复制/nginx源码目录/ objs 目录下的 nginx至安装的Nginx目录下,重启Nginx生效。

对于Nginx,可以修改nginc.conf配置文件,改变“405错误”为“200 ok”,并配置location来解决,方法如下:

server
{
    listen       80;
    server_name  www.kiccleaf.com;
    index index.html index.htm index.php;
    root  /data/kiccleaf;  

    if ($host != 'www.kiccleaf.com' ) {
         rewrite ^/(.*)$ http://www.kiccleaf.com/$1 permanent;
    }
    location ~ .*\.(php|php5)?$
    {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    #添加以下405代码
    error_page   405 =200 @405;
    location @405
    {
        root  /data/kiccleaf;
    }
}


也可以简单的编写成

server
{
    listen       80;
    server_name  www.kiccleaf.com;
    index index.html index.htm index.php;
    root  /data/kiccleaf;  

    if ($host != 'www.kiccleaf.com' ) {
         rewrite ^/(.*)$ http://www.kiccleaf.com/$1 permanent;
    }
    location ~ .*\.(php|php5)?$
    {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      include fcgi.conf;
    }
    #添加以下405代码
    error_page 405 =200 $uri;
}
Leave a Comment

Linux下chkconfig命令详解

chkconfig命令主要用来更新(启动或停止)和查询系统服务的运行级信息。谨记chkconfig不是立即自动禁止或激活一个服务,它只是简单的改变了符号连接。

使用语法:
chkconfig [–add][–del][–list][系统服务] 或 chkconfig [–level <等级代号>][系统服务][on/off/reset]

chkconfig在没有参数运行时,显示用法。如果加上服务名,那么就检查这个服务是否在当前运行级启动。如果是,返回true,否则返回false。如果在服务名后面指定了on,off或者reset,那么chkconfi 会改变指定服务的启动信息。on和off分别指服务被启动和停止,reset指重置服务的启动信息,无论有问题的初始化脚本指定了什么。on和off开关,系统默认只对运行级3,4,5有效,但是reset可以对所有运行级有效。

参数用法:
–add  增加所指定的系统服务,让chkconfig指令得以管理它,并同时在系统启动的叙述文件内增加相关数据。
–del  删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据。
–level<等级代号>  指定读系统服务要在哪一个执行等级中开启或关毕。
等级0表示:表示关机
等级1表示:单用户模式
等级2表示:无网络连接的多用户命令行模式
等级3表示:有网络连接的多用户命令行模式
等级4表示:不可用
等级5表示:带图形界面的多用户模式
等级6表示:重新启动
需要说明的是,level选项可以指定要查看的运行级而不一定是当前运行级。对于每个运行级,只能有一个启动脚本或者停止脚本。当切换运行级时,init不会重新启动已经启动的服务,也不会再次去停止已经停止的服务。

chkconfig –list [name]:显示所有运行级系统服务的运行状态信息(on或off)。如果指定了name,那么只显示指定的服务在不同运行级的状态。
chkconfig –add name:增加一项新的服务。chkconfig确保每个运行级有一项启动(S)或者杀死(K)入口。如有缺少,则会从缺省的init脚本自动建立。
chkconfig –del name:删除服务,并把相关符号连接从/etc/rc[0-6].d删除。
chkconfig [–level levels] name:设置某一服务在指定的运行级是被启动,停止还是重置。

运行级文件:
每个被chkconfig管理的服务需要在对应的init.d下的脚本加上两行或者更多行的注释。第一行告诉chkconfig缺省启动的运行级以及启动和停止的优先级。如果某服务缺省不在任何运行级启动,那么使用 – 代替运行级。第二行对服务进行描述,可以用\ 跨行注释。
例如,random.init包含三行:
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for \
# higher quality random number generation.

使用范例:

chkconfig --list        #列出所有的系统服务
chkconfig --add httpd        #增加httpd服务
chkconfig --del httpd        #删除httpd服务
chkconfig --level httpd 2345 on        #设置httpd在运行级别为2、3、4、5的情况下都是on(开启)的状态
chkconfig --list        #列出系统所有的服务启动情况
chkconfig --list mysqld        #列出mysqld服务设置情况
chkconfig --level 35 mysqld on        #设定mysqld在等级3和5为开机运行服务,--level 35表示操作只在等级3和5执行,on表示启动,off表示关闭
chkconfig mysqld on        #设定mysqld在各等级为on,“各等级”包括2、3、4、5等级

如何增加一个服务:
1.服务脚本必须存放在/etc/ini.d/目录下;
2.chkconfig –add servicename
在chkconfig工具服务列表中增加此服务,此时服务会被在/etc/rc.d/rcN.d中赋予K/S入口了;
3.chkconfig –level 35 mysqld on
修改服务的默认启动等级。

Leave a Comment

利用Linux命令find查找PHP木马

Linux本身相对Win来讲安全点,因为好多人不会命令,这就是优点啊!但网站现在开源的这么多,所以漏洞也相对较多,一不小心网站被上传木马也是常有的事情。
收集和整理了一下利用find命令来查找一下是否网站被种木马了,无非是根据木马的特征代码来配对。

find ./ -name "*.php" |xargs egrep "phpspy|c99sh|milw0rm|eval\(gunerpress|eval\(base64_decode|spider_bc"> /tmp/php.txt

grep -r –include=*.php  '[^a-z]eval($_POST' . > /tmp/eval.txt

grep -r –include=*.php  'file_put_contents(.*$_POST\[.*\]);' . > /tmp/file_put_contents.txt

find ./ -name "*.php" -type f -print0 | xargs -0 egrep "(phpspy|c99sh|milw0rm|eval\(gzuncompress\(base64_decode|eval\(base64_decode|spider_bc|gzinflate)" | awk -F: '{print $1}' | sort | uniq

查找最近一天被修改的PHP文件

find -mtime -1 -type f -name \*.php

修改网站php文件权限,只读

find -type f -name \*.php -exec chmod 444 {} \;

修改网站目录权限

find ./ -type d -exec chmod 555{} \;
Leave a Comment

php编译中遇到error解决办法![转]

在编译php的过程中,经常会出现一些错误信息,网络上搜索了一下还是比较有用的,收藏一下!

1) Configure: error: xml2-config not found. Please check your libxml2 installation.
Solutions :
Quote:
#yum install libxml2 libxml2-devel (For Redhat & Fedora)
# aptitude install libxml2-dev      (For ubuntu)

2) Checking for pkg-config… /usr/bin/pkg-config 
configure: error: Cannot find OpenSSL’s <evp.h>
Solutions :
Quote:
#yum install openssl openssl-devel

3) Configure: error: Please reinstall the BZip2 distribution
Solutions :
Quote:
# yum install bzip2 bzip2-devel

4) Configure: error: Please reinstall the libcurl distribution - 
easy.h should be in <curl-dir>/include/curl/
Solutions :
Quote:
# yum install curl curl-devel   (For Redhat & Fedora)
# install libcurl4-gnutls-dev    (For Ubuntu) 

5) Configure: error: libjpeg.(also) not found.
Solutions :
Quote:
# yum install libjpeg libjpeg-devel

6) Configure: error: libpng.(also) not found.
Solutions :
Quote:
# yum install libpng libpng-devel

7) Configure: error: freetype.h not found. 
Solutions :
Quote:
#yum install freetype-devel

8) Configure: error: Unable to locate gmp.h
Solutions :
Quote:
# yum install gmp-devel

9) Configure: error: Cannot find MySQL header files under /usr. 
Note that the MySQL client library is not bundled anymore!
Solutions :
Quote:
# yum install mysql-devel            (For Redhat & Fedora)
# apt-get install libmysql++-dev      (For Ubuntu) 

10) Configure: error: Please reinstall the ncurses distribution
Solutions :
Quote:
# yum install ncurses ncurses-devel

11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
Solutions :
Quote:
# yum install unixODBC-devel

12) Configure: error: Cannot find pspell
Solutions :
Quote:
# yum install pspell-devel

13) configure: error: mcrypt.h not found. Please reinstall libmcrypt.
Solutions :
Quote:
# yum install libmcrypt libmcrypt-devel    (For Redhat & Fedora)
# apt-get install libmcrypt-dev 

14) Configure: error: snmp.h not found. Check your SNMP installation.
Solutions :
Quote:
# yum install net-snmp net-snmp-devel

15)configure: error: Please reinstall libmhash – I cannot find mhash.h
#yum install mhash-devel
Leave a Comment

Nginx 301重定向配置方法

有时候顶级域名不想使用,只想用www域名,那么需要做301重定向,在Nginx下的方法有以下两种我较常用的方法:

第一种方式建立一个kiccleaf.com.conf文件输入以下内容

server {
    listen 80;
    server_name  kiccleaf.com;
    location / {
            rewrite ^(.*) http://www.kiccleaf.com$1 permanent;
    }
}

第二种方式在原有的www.kiccleaf.com.conf文件里添加至server_name下一行(我个人一般采用这种方式,比较方便在一个配置文件中就可以解决了。)

server{
   listen 80;
   server_name www.kiccleaf.com kiccleaf.com ;
   if ($host != 'www.kiccleaf.com' ){
      rewrite ^/(.*)$ http://www.kiccleaf.com/$1 permanent;
   }
  ...
}
Leave a Comment

FreeBSD8.2系统安装视频[原创]

FreeBSD系统最小化安装其实几分钟就搞定了,以最快速的速度操作的话,我估计两分钟就可以安装完成。首先这里放上最小安装的视频,以后慢慢把系统的配置视频放上来。
[wposflv src=”http://www.kiccleaf.com/flv/FreeBSD8.2.flv” height=”400″ width=”600″]

Leave a Comment