CentOS Shadowsocks C 服务部署与配置详解
环境准备与依赖安装
执行系统更新确保软件包为最新版本:
yum update -y && yum install epel-release -y
安装编译基础工具链:
yum groupinstall "Development Tools" -y
yum install git libsodium-devel c-ares-devel -y
源码编译与安装
克隆Shadowsocks C项目仓库:
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
执行编译安装流程:
./configure && make
make install
服务配置与启动
创建配置文件/etc/shadowsocks.json
:
{
"server":"0.0.0.0",
"server_port":8388,
"password":"your_secure_password",
"method":"chacha20-ietf-poly1305",
"timeout":300
}
启动Shadowsocks服务:
ss-server -c /etc/shadowsocks.json -d start
防火墙与安全加固
开放服务端口并设置永久生效:
firewall-cmd --permanent --add-port=8388/tcp
firewall-cmd --permanent --add-port=8388/udp
firewall-cmd --reload
建议配置SELinux策略或设置为宽容模式:
setenforce 0
系统服务与自动启动
创建Systemd服务文件/etc/systemd/system/ss.service
:
[Unit]
Description=Shadowsocks Server
After=network.target
[Service]
ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks.json
[Install]
WantedBy=multi-user.target
启用服务自启动:
systemctl enable ss.service
systemctl start ss.service