Create ShadowSocks on VPS

This is a log to establish & install ShadowSock on VPS (Centos).

If you do not have zlib-devel and openssl-devel, then you need to install it.

sudo yum install -y zlib-devel openssl-devel

Detailed steps:

git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
./configure --prefix=/usr && make
sudo make install
sudo cp ./rpm/SOURCES/etc/init.d/shadowsocks-libev /etc/init.d/
sudo chmod +x /etc/init.d/shadowsocks-libev
sudo mkdir /etc/shadowsocks-libev
sudo cp ./debian/config.json /etc/shadowsocks-libev/
sudo nano /etc/shadowsocks-libev/config.json

Then change the configuration file accordingly.

{
 "server":"0.0.0.0",
 "server_port":8388,
 "local_address": "127.0.0.1",
 "local_port":1080,
 "password":"barfoo!",
 "timeout":300,
 "method":"aes-256-cfb",
 "fast_open": false,
 "workers": 1
}

For CentOS 6.*, just do

sudo service shadowsocks-libev start

And we are good. For CentOS 7, you need to do the followings.

sudo -i
nano /etc/systemd/system/shadowsocks-server.service

And then input the following: (assuming ss-server is at /usr/bin/)

[Unit]
Description=Shadowsocks service
After=network.target

[Service]
Type=simple
User=nobody
ExecStart=/usr/bin/ss-server -c /etc/shadowsocks-libev/config.json
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true
KillMode=process
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

For previously server-port setting as a different one less than 1024, you need to set here User to root ([1]). Then save the file.

Now just do: (change 8388 to your port)

systemctl start shadowsocks-server.service
systemctl enable shadowsocks-server.service
firewall-cmd --permanent --add-port=8388/tcp
firewall-cmd --reload

Leave a Reply

Your email address will not be published. Required fields are marked *