Centos上安装搜狗输入法详细指南
CentOS作为一种重要的Linux发行版,被广泛应用于服务器、桌面和移动设备等各个领域,CentOS自带的中文输入法难以满足用户的需求,因此许多用户选择安装搜狗输入法以提升输入体验,本文将详细介绍如何在CentOS上安装搜狗输入法。

安装步骤
1. 配置清华开源镜像(可选)
如果您是教育网用户,推荐使用清华开源镜像,因为支持IPv6,下载速度较快,以下是配置步骤:
- 备份原先的CentOSBase.repo
- sudo mv /etc/yum.repos.d/CentOSBase.repo /etc/yum.repos.d/CentOSBase.repo.bak
- 新建一个CentOSBase.repo文件
- sudo vim /etc/yum.repos.d/CentOSBase.repo
在文件中粘贴以下内容并保存退出:
- CentOSBase.repo
- #
- The mirror system uses the connecting IP address of the client and the
- update status of each mirror to pick mirrors that are updated to and
- geographically close to the client. You should use this for CentOS updates
- unless you are manually picking other mirrors.
- #
- If the mirrorlist= does not work for you, as a fall back you can try the
- remarked out baseurl= line instead.
- #
- #
- [base]
- name=CentOS$releasever Base
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
- gpgcheck=1
- gpgkey=file:///etc/pki/rpmgpg/RPMGPGKEYCentOS7
- #released updates
- [updates]
- name=CentOS$releasever Updates
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
- gpgcheck=1
- gpgkey=file:///etc/pki/rpmgpg/RPMGPGKEYCentOS7
- #additional packages that may be useful
- [extras]
- name=CentOS$releasever Extras
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
- gpgcheck=1
- gpgkey=file:///etc/pki/rpmgpg/RPMGPGKEYCentOS7
2. 安装依赖包
切换到root用户并更新YUM源:
- su root
- yum update
卸载ibus:

- rpm e nodeps ibus
安装EPEL源:
- yum y install epelrelease
安装fcitx环境、qtwebkit包和alien转换工具:
- yum install y qtwebkit alien dpkg opencc redhatlsb fcitx fcitxconfigtool fcitxpinyin
3. 下载并安装搜狗输入法
从搜狗输入法官网下载搜狗输入法for Linux版本的DEB安装包:
- cd ~/downloads # 或者其他目录
- wget http://cdn2.ime.sogou.com/dl/index/1524572264/sogoupinyin_2.2.0.0108_amd64.deb
使用alien将DEB包转换为RPM包:
- alien r scripts sogoupinyin_2.2.0.0108_amd64.deb
强制安装转换后的RPM包:

- rpm ivh force sogoupinyin2.2.0.01082.x86_64.rpm
4. 配置环境变量
将搜狗输入法词语库转移至fcitx:
- cp /usr/lib/x86_64linuxgnu/fcitx/fcitxsogoupinyin.so /usr/lib64/fcitx/
为新目录授权:
- chown R 776 /usr/share/fcitxsogoupinyin/
检查QT依赖及fcitxconfigtool、fcitxpinyin是否已安装:
- yum y install fcitxqt5 fcitxconfigtool fcitxpinyin
修改环境变量,编辑/etc/profile
文件:
- vim /etc/profile
在文件末尾添加以下内容:
- export XIM_PROGRAM=fcitx
- export GTK_IM_MODULE=fcitx
- export QT_IM_MODULE=fcitx
- export XMODIFIERS="@im=fcitx"
保存并退出编辑器。
5. 配置输入法框架
关闭gnomeshell对键盘的监听,然后切换输入法为fcitx:
- gsettings set org.gnome.settingsdaemon.plugins.keyboard active false
- imsettingsswitch fcitx
重新启动系统:
- reboot
常见问题与解答(FAQs)
Q1: 安装过程中提示“没有权限”,怎么办?
A1: 使用sudo
命令,以管理员权限运行安装程序。
- sudo ./install
Q2: 安装完成后无法使用搜狗输入法,怎么办?
A2: 检查是否正确设置了环境变量,可以重新编辑/etc/profile.d/sogou.sh
文件,确保环境变量设置正确。
- export GTK_IM_MODULE=sogoupy
- export QT_IM_MODULE=sogoupy
- export XMODIFIERS=@im=sogoupy