php安装mssql扩展

# 关于freetds编译时with-tdsver参数
# 参考:https://www.freetds.org/userguide/choosingtdsprotocol.htm
# 在FreeTDS 1.1版本之后,可以设置为auto,版本之前需要手动指定。
以前写过mssql模块安装,这次只是补充编译freetds时指定with-tdsver参数
1、下载freetds及php源码包

[root@VM_0_11_centos ~]# wget -c ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.1.21.tar.gz
[root@VM_0_11_centos ~]# wget -c http://museum.php.net/php5/php-5.2.17.tar.gz

2、安装freetds
# 解压freetds源码包

[root@VM_0_11_centos ~]# tar zxvf freetds-1.1.21.tar.gz
[root@VM_0_11_centos ~]# cd freetds-1.1.21/

# 开始编译安装

[root@VM_0_11_centos ~]# ./configure --prefix=/usr/local/freetds --with-tdsver=7.3 --enable-msdblib
[root@VM_0_11_centos ~]# make && make install

3、编译mssql模块
# 解压php源码包

[root@VM_0_11_centos ~]# tar zxvf php-5.2.17.tar.gz 

# 进入mssql扩展目录

[root@VM_0_11_centos ~]# cd php-5.2.17/ext/mssql/

# 生成configure

[root@VM_0_11_centos mssql]# /www/server/php/52/bin/phpize 

# 开始编译

[root@VM_0_11_centos php-5.2.17]# ./configure  --with-php-config=/www/server/php/52/bin/php-config --with-mssql=/usr/local/freetds
[root@VM_0_11_centos php-5.2.17]# make && make install

4、编辑php.ini文件,加入mssql扩展,在 491 行下面添加(如果不会用vi编辑器,可直接将文件下载改完再传上去)

[root@VM_0_11_centos ~]# vi /www/server/php/52/etc/php.ini
extension_dir = "/www/server/php/52/lib/php/extensions/no-debug-non-zts-20060613/"
extension = mssql.so # 新增行

保存退出,重启php或者重启服务器。

nodejs项目启动报错 cannot find module ‘ipaddr.js’

用pm2 start /www/project 启动项目提示错误
用pm2 logs project查看报 cannot find module ‘ipaddr.js’错误

以为是没有ipaddr.js这个文件,find搜索了下,项目目录里面是有的。

1、尝试npm install安装依赖,此方法未解决。

2、删除项目下的node_modules文件夹并清除缓存:

rm -rf node_modules
npm cache clean --force
npm install

启动:

pm2 start project

这样问题才解决。

解决inode使用100%

# 从根目录开始确定哪个目录文件多

for i in /*; do echo $i; find $i | wc -l; done

# 根据最多的目录,进入,再定位子目录,确定哪个目录占的多

for i in ./*; do echo $i; find $i | wc -l; done

# 根据时间来删除(7天前的),防止出现 Argument list too long 问题

find .  -ctime +7 -name "*" | xargs -i rm -rf {}

如果提示Argument list too long ,就把7加大。
或者用rsync同步并删除实现
参考:https://www.rootop.org/pages/4316.html

nginx中if和location优先级问题

问题:nginx要实现代理wss访问(websocket secure),但是配置以后测试提示404,配置如下:
# nginx配置

server
{
	#略过部分配置

    location /wss {
		proxy_pass http://127.0.0.1:8202;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		proxy_set_header X-Real-IP $remote_addr;
		proxy_read_timeout  84000;
	}
	
	if (!-e $request_filename) {
		rewrite ^/(.*)$ /index.php/$1 last;
		break;
	}
}

提示404也就是未匹配到location,发现是下面if段的问题。
把配置改为如下:

server
{
	#略过部分配置
	
    location / {
      if (!-e $request_filename) {
          rewrite ^/(.*)$ /index.php/$1 last;
          break;
      }
    }
	
    location /wss {
		proxy_pass http://127.0.0.1:8202;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		proxy_set_header X-Real-IP $remote_addr;
		proxy_read_timeout  84000;
	}
	
}

这样才实现访问到location /wss {} 段。
查资料说if相当于在内部实现一个location,如果匹配了,只会执行这个内部的动作。
换句话说,if和location同级的时候,if优先级高于location。
所以把if(){}放到location / {}中后问题解决。

man命令查看系统调用方法

# 根据资料输入命令可以查看系统调用的方法描述,但是提示没有帮助文档。

[root@VM_0_8_centos ~]# man 2 read
No manual entry for read in section 2

# 原因:默认只能看第一区段,其他区段需要再安装。

# 所有的区段:
区段1:用户指令
区段2:系统调用
区段3:程序库调用
区段4:设备
区段5:文件格式
区段6:游戏
区段7:杂项
区段8:系统指令
区段9:内核内部指令
区段n:Tcl或Tk指令

# 安装所有区段 (英文版)

yum install man-pages -y

# 中文手册,相当于安装汉化包,需要系统支持中文

yum install man-pages-zh-CN -y

# 系统中文支持安装(centos7)

yum install kde-l10n-Chinese

# 临时设置系统中文显示

export LANG=zh_CN.UTF-8