安装服务端和客户端
wget -O /etc/yum.repos.d/mqtt.repo download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-6/home:oojah:mqtt.repo
yum update
yum install mosquitto mosquitto-clients
chkconfig mosquitto on
service mosquitto start
安装服务端和客户端
wget -O /etc/yum.repos.d/mqtt.repo download.opensuse.org/repositories/home:/oojah:/mqtt/CentOS_CentOS-6/home:oojah:mqtt.repo
yum update
yum install mosquitto mosquitto-clients
chkconfig mosquitto on
service mosquitto start
给root设置一个密码,允许远程通过密码登录
chmod 400 xxx.pem
ssh -i xxx.pem ec2-user@host-ip
sudo passwd root
sudo su -
vim /etc/ssh/sshd_config
/etc/ssh/sshd_config内容如下
PermitRootLogin yes
PasswordAuthentication yes
UsePAM yes
然后
service sshd reload
amazon aws如果采用redhat需要额外收授权费,目前aws官方2014.3基于centos 6,许多软件版本较旧,可以通过epel软件仓库安装一些新软件
yum-config-manager --enable epel
yum update
yum groupinstall "Development tools" -y
yum install openssl-devel libxslt-devel libxml2-devel libffi-devel -y
vim /etc/yum.repos.d/MariaDB.repo
# MariaDB 5.5 CentOS repository list - created 2014-09-13 05:43 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装MariaDB客户端
yum install MariaDB-client mysql-devel -y
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum-config-manager --enable remi
yum install redis -y
vim /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
安装mongodb客户端
yum update
yum install mongodb-org-shell -y
# yum install centos-release-SCL (aliyun only)
yum install python27*
yum install freetype-devel libjpeg-devel libpng-devel
# scl enable python27 bash (aliyun only)
virtualenv --no-site-packages /data/pyenv
source /data/pyenv/bin/activate
pip install redis cryptography sqlalchemy flask simplejson mongoengine python-amazon-product-api scrapy mysql-python gunicorn gevent
#install glusterfs repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#fix it for amazon linux
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
#install glusterfs
yum install -y glusterfs-fuse
#setup fstab
echo "172.31.42.77:/pcvol /data_pcvol glusterfs defaults,noatime 0 0" >> /etc/fstab
#mount
mkdir /data_pcvol
mount -a
ls /data_pcvol
lsblk
mkfs -t ext4 /dev/xvdf
echo '/dev/xvdf /data_log ext4 defaults,nofail 0 2' >> /etc/fstab
mkdir /data_log
mount -a
vim /etc/yum.repos.d/mongodb.repo
[mongodb-org]
name=MongoDB Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el$releasever/
gpgcheck=0
enabled=1
yum makecache
yum install mongodb-org
chkconfig mongod on
service mongod start
lsblk
yum install -y xfsprogs
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
mkfs.xfs -i size=512 /dev/xvdf
mkdir -p /export/xvdf
echo "/dev/xvdf /export/xvdf xfs defaults,nofail,noatime 1 2" >> /etc/fstab
mount -a
#install glusterfs
yum install -y glusterfs{-fuse,-server}
#start glusterfs
service glusterd start
#turn on auto-start
chkconfig glusterd on
mkdir /export/xvdf/brick1
gluster volume create pcvol 172.31.42.77:/export/xvdf/brick1
gluster volume start pcvol
gluster volume info
gluster volume status
#install glusterfs repo
wget -P /etc/yum.repos.d http://download.gluster.org/pub/gluster/glusterfs/LATEST/EPEL.repo/glusterfs-epel.repo
#fix it for amazon linux
sed -i 's/$releasever/6/g' /etc/yum.repos.d/glusterfs-epel.repo
#install glusterfs
yum install -y glusterfs-fuse
#setup fstab
echo "172.31.42.77:/pcvol /data_pcvol glusterfs defaults,noatime 0 0" >> /etc/fstab
#mount
mkdir /data_pcvol
mount -a
ls /data_pcvol
原文链接:http://yanue.net/post-140.html
sudo yum remove ibus
gsettings set org.gnome.settings-daemon.plugins.keyboard active false
yum install fcitx fcitx-devel fcitx-configtool fcitx-cloudpinyin fcitx-pinyin
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
上面步骤完成之后其实就可以使用Fcitx输入法
不过看到搜狗输入法都已经出deb包了
所以就想着安装个搜狗输入法到Fcitx上去。
从下面的连接地址下载对应的deb包、32位系统用i386.deb、64位系统用amd64.deb
http://mirrors.ustc.edu.cn/deepin/pool/non-free/f/fcitx-sogoupinyin-release/
随便在从如下地址下载一个搜狗输入法的皮肤
http://mirrors.ustc.edu.cn/deepin/pool/main/f/fcitx-skins/
接着我们把解压出来的.so文件移动到Fcitx的指定目录即可(64位为例)
cp /usr/lib/x86_64-linux-gnu/fcitx/fcitx-sogoupinyin.so /usr/lib64/fcitx/
最后加上执行权限
chmod +x /usr/lib64/fcitx/fcitx-sogoupinyin.so
原文链接:http://fewspider.github.io/linux/Sublime-Text-Chinese-input-under-Linux.html
复制以下内容到sublime-imfix.c
/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
LD_PRELOAD=./libsublime-imfix.so subl
*/
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
typedef GdkSegment GdkRegionBox;
struct _GdkRegion
{
long size;
long numRects;
GdkRegionBox *rects;
GdkRegionBox extents;
};
GtkIMContext *local_context;
void
gdk_region_get_clipbox (const GdkRegion *region,
GdkRectangle *rectangle)
{
g_return_if_fail (region != NULL);
g_return_if_fail (rectangle != NULL);
rectangle->x = region->extents.x1;
rectangle->y = region->extents.y1;
rectangle->width = region->extents.x2 - region->extents.x1;
rectangle->height = region->extents.y2 - region->extents.y1;
GdkRectangle rect;
rect.x = rectangle->x;
rect.y = rectangle->y;
rect.width = 0;
rect.height = rectangle->height;
//The caret width is 2;
//Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
gtk_im_context_set_cursor_location(local_context, rectangle);
}
}
//this is needed, for example, if you input something in file dialog and return back the edit area
//context will lost, so here we set it again.
static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
{
XEvent *xev = (XEvent *)xevent;
if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window");
if(GDK_IS_WINDOW(win))
gtk_im_context_set_client_window(im_context, win);
}
return GDK_FILTER_CONTINUE;
}
void gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window)
{
GtkIMContextClass *klass;
g_return_if_fail (GTK_IS_IM_CONTEXT (context));
klass = GTK_IM_CONTEXT_GET_CLASS (context);
if (klass->set_client_window)
klass->set_client_window (context, window);
if(!GDK_IS_WINDOW (window))
return;
g_object_set_data(G_OBJECT(context),"window",window);
int width = gdk_window_get_width(window);
int height = gdk_window_get_height(window);
if(width != 0 && height !=0) {
gtk_im_context_focus_in(context);
local_context = context;
}
gdk_window_add_filter (window, event_filter, context);
}
执行以下命令生成SO文件:
gcc -shared -o libsublime-imfix.so sublime-imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
编译时如果提示 gtk/gtk.h: No such file or directory,需要先安装编译工具
yum install gtk2-devel
LD_PRELOAD=./libsublime-imfix.so subl
复制subl目录下的sublime_text.desktop到/usr/share/applications/sublime_text.desktop并修改exec与icon
Icon=/opt/sublime_text_3/Icon/256x256/sublime-text.png
Exec=bash -c 'LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so /opt/sublime_text_3/sublime_text' %F
现在,使用sublime可以支持fcitx输入法输入中文了,要将ibus替换成fcitx请参考我的另外一篇文章Fedora 20安装Fcitx输入法并安装搜狗资源包
大部分时候是因为浏览器编码错误:
vim `which google-chrome`
在EXPORT下面加入:
LANG="zh_CN.UTF-8"
CREATE TABLE sph_counter
(
counter_id INTEGER PRIMARY KEY NOT NULL,
max_doc_id bigint NOT NULL
);
下载地址:http://www.sphinx-search.com/
wget http://www.sphinx-search.com/downloads/sphinx-for-chinese-2.2.1-dev-r4311.tar.gz
tar -xvf sphinx-for-chinese-2.2.1-dev-r4311.tar.gz
cd sphinx-for-chinese-2.2.1-dev-r4311
./configure --prefix=/usr/local/sphinx-for-chinese --with-mysql --enable-id64
make -j4 install
下载词典:
wget https://sphinx-for-chinese.googlecode.com/files/xdict_1.1.tar.gz
tar -xzf xdict_1.1.tar.gz
/usr/local/sphinx-for-chinese/bin/mkdict xdict_1.1.txt /usr/local/sphinx-for-chinese/etc/xdict
在索引配置项中添加以下两项:
charset_type = utf-8
chinese_dictionary = /usr/local/sphinx-for-chinese/etc/xdict
indexer
{
mem_limit = 512M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = /usr/local/sphinx-for-chinese/var/log/searchd.log
query_log = /usr/local/sphinx-for-chinese/var/log/query.log
read_timeout = 5
max_children = 30
pid_file = /usr/local/sphinx-for-chinese/var/log/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
# binlog_path = /usr/local/sphinx-for-chinese/var/data 关闭binlog日志
}
<?php
$s = new SphinxClient;
$s->setServer("192.168.2.101", 9312);
$s->setMatchMode(SPH_MATCH_ALL);
$s->setMaxQueryTime(3);
$keywords = array(
'the',
'一分钱补差价',
'一分钱 补差价',
'补差价 一分钱',
'一分钱乱补差价',
'一分钱 乱 补差价',
'一分钱',
'补差价',
);
foreach ($keywords as $k) {
$result = $s->query($k);
echo $k,"\n";
if(isset($result['matches']) ) {
print_r($result['matches']);
}
}
gsettings set org.gnome.gedit.preferences.encodings auto-detected "['UTF-8', 'GB18030', 'GB2312', 'GBK', 'BIG5', 'CURRENT', 'UTF-16']"
gsettings set org.gnome.gedit.preferences.encodings shown-in-menu "['UTF-8', 'GB18030', 'GB2312', 'GBK', 'BIG5', 'CURRENT', 'UTF-16']"
yum install dconf-tools,然后运行dconf-editor(ctrl+f2),依次点开->org->gnome->gedit->preferences->encodings设置如上即可