centos7下编译安装libiconv-1.14 error: ‘gets’ undeclared here (not in a function)

centos7下编译安装libiconv-1.14报错,信息如下:

In file included from progname.c:26:0:
./stdio.h:1010:1: error: ‘gets’ undeclared here (not in a function)
 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
 ^
make[1]: *** [progname.o] Error 1
make[1]: Leaving directory `/root/lnmp1.2/source/libiconv-1.14/srclib'
make: *** [all] Error 2

解决方法:
编辑 libiconv-1.14/srclib/stdio.h 文件,这个文件在make之后才会生成,源码中是没有的。

1007 /* It is very rare that the developer ever has full control of stdin,
1008 so any use of gets warrants an unconditional warning. Assume it is
1009 always declared, since it is required by C89. */
1010 _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");

第1010行,把 _GL_WARN_ON_USE (gets, “gets is a security hole – use fgets instead”); 删掉
改为:

#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

变成如下:

继续make && make install 通过

在Linux中让echo命令显示带颜色的字

原文来自:http://onlyzq.blog.51cto.com/1228/546459

echo显示带颜色,需要使用参数-e
格式如下:
echo -e “\033[字背景颜色;文字颜色m字符串\033[0m”
例如:
echo -e “\033[41;37m TonyZhang \033[0m”
其中41的位置代表底色, 37的位置是代表字的颜色

注:
1、字背景颜色和文字颜色之间是英文的“”””
2、文字颜色后面有个m
3、字符串前后可以没有空格,如果有的话,输出也是同样有空格

下面看几个例子:

echo -e “\033[30m 黑色字 \033[0m”
echo -e “\033[31m 红色字 \033[0m”
echo -e “\033[32m 绿色字 \033[0m”
echo -e “\033[33m 黄色字 \033[0m”
echo -e “\033[34m 蓝色字 \033[0m”
echo -e “\033[35m 紫色字 \033[0m”
echo -e “\033[36m 天蓝字 \033[0m”
echo -e “\033[37m 白色字 \033[0m”
echo -e “\033[40;37m 黑底白字 \033[0m”
echo -e “\033[41;37m 红底白字 \033[0m”
echo -e “\033[42;37m 绿底白字 \033[0m”
echo -e “\033[43;37m 黄底白字 \033[0m”
echo -e “\033[44;37m 蓝底白字 \033[0m”
echo -e “\033[45;37m 紫底白字 \033[0m”
echo -e “\033[46;37m 天蓝底白字 \033[0m”
echo -e “\033[47;30m 白底黑字 \033[0m”

控制选项说明 :

\33[0m 关闭所有属性
\33[1m 设置高亮度
\33[4m 下划线
\33[5m 闪烁
\33[7m 反显
\33[8m 消隐
\33[30m — \33[37m 设置前景色
\33[40m — \33[47m 设置背景色
\33[nA 光标上移n行
\33[nB 光标下移n行
\33[nC 光标右移n行
\33[nD 光标左移n行
\33[y;xH设置光标位置
\33[2J 清屏
\33[K 清除从光标到行尾的内容
\33[s 保存光标位置
\33[u 恢复光标位置
\33[?25l 隐藏光标
\33[?25h 显示光标

利用wkhtmltopdf把html转换为pdf或jpg

系统:centos6 x64

官方网站: http://wkhtmltopdf.org
What is it?
wkhtmltopdf and wkhtmltoimage are open source (LGPLv3) command line tools to render HTML into PDF and various image formats using the Qt WebKit rendering engine.
These run entirely “headless” and do not require a display or display service.

安装:

[root@www ~]# wget -c http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
[root@www ~]# yum install -y xz*
[root@www ~]# xz -d wkhtmltox-0.12.3_linux-generic-amd64.tar.xz
[root@www ~]# tar xvf wkhtmltox-0.12.3_linux-generic-amd64.tar
[root@www ~]# cp -R wkhtmltox /usr/local/

拷贝windows字体文件到linux中,否则生成pdf或图像会显示方框乱码。
把C:\Windows\Fonts下的 “微软雅黑”或”宋体 常规”(一个就行) 上传到linux下的/usr/share/fonts

[root@www ~]# cp msyh.ttc simsun.ttc /usr/share/fonts

生成pdf:

[root@www ~]# /usr/local/wkhtmltox/bin/wkhtmltopdf https://www.rootop.org ~/rootop.pdf

生成jpg:

[root@www ~]# /usr/local/wkhtmltox/bin/wkhtmltoimage https://www.rootop.org ~/rootop.jpg

subversion钩子更新代码到远程服务器

原先svn和web服务器在一台机器上,直接通过svn的钩子实现代码提交时更新某个项目。
现在svn和web服务器分开,就无法实现本地更新了。

方法1:
通过rsync
依然在svn服务器上有一个项目目录,钩子还是实现本地更新,当本地目录发生改变,通过inotify+rsync实现同步到远端。
需要配置钩子,配置inotify rsync。
过程略。

方法2:
通过ssh
首先创建ssh无秘钥访问,实现不用输入密码就可以远程登录,过程略。
从svn检出代码:

svn checkout svn://xxx.xxx.xxx.xxx/xxx --username xxx --password xxx

然后在钩子中通过ssh执行命令。

ssh root@xxxx 'svn update /var/www/html/xxx --username xxx --password xxx'

第二种方法相对实现要简单很多。不需要第三方软件。

linux下切换svn服务器地址 svn switch –relocate

linux下,如果项目所属的svn服务器发生ip变更,就需要修改客户端配置,更改为新的仓库地址。windows下为直接右键项目目录 -> TortoiseSVN -> Relocate 。linux就需要用命令去更改。方法如下:

切换到项目路径:
cd /xxx/xxx/xxx

查看原仓库地址信息:

[root@xxx xxx]# svn info
Path: .
URL: svn://1x.1x.1x.1x/repo
<strong>Repository Root: svn://1x.1x.1x.1x/repo  </strong>#svn地址
Repository UUID: dbe02c4e-6fd4-4fae-9ca0-81f6af0cb7ee
Revision: 237
Node Kind: directory
Schedule: normal
Last Changed Author: <strong>rootop  </strong> #svn账户
Last Changed Rev: 237
Last Changed Date: 2016-01-27 16:21:29 +0800 (Wed, 27 Jan 2016)

切换svn服务器地址:

svn switch --relocate 旧地址  新地址
[root@xxx xxx]# svn switch --relocate svn://1x.1x.1x.1x/repo svn://2x.2x.2x.2x/repo