How to build a sour ss Centos7

How to build a sour centos7

Explanation

Personal use of the words, ss (sour) is more convenient than ssr (sour milk) points, mainly depends on the individual.
This article is only for Centos system, the other system part of the code of this article is slightly different, not common to other systems.

1. System Configuration

Centos 7 x64

2. Depending on the installation

The following code execution

yum update -y
yum install -y pcre pcre-devel git gettext gcc autoconf libtool automake make asciidoc xmlto c-ares-devel libev-devel


wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz && tar xf libsodium-1.0.18.tar.gz && cd libsodium-1.0.18 && ./configure && make -j2 && make install && cd /
echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

export MBEDTLS_VER=2.6.0
wget https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz
tar xvf mbedtls-$MBEDTLS_VER-gpl.tgz
pushd mbedtls-$MBEDTLS_VER
make SHARED=1 CFLAGS=-fPIC
make DESTDIR=/usr install
popd
ldconfig

# clean directory
rm -rf /tmp/shadowsocks-libev

# compile and install
cd /tmp
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init --recursive
./autogen.sh
./configure
make
make install
cd ..
rm -rf /tmp/shadowsocks-libev

mkdir /etc/shadowsocks-libev
touch /etc/shadowsocks-libev/config.json

3. Profiles

/Etc/shadowsocks-libev/config.json profile
will add the following code file

{
    "server_host": "你的服务器ip或域名",
    "server_port": 8111,
    "password":"密码",
    "timeout":300,
    "method":"rc4-md5",
    "fast_open": false
}

4. Set the background

New file / etc / default / shadowsocks-libev
to add the following code file

# Defaults for shadowsocks initscript
# sourced by /etc/init.d/shadowsocks-libev
# installed at /etc/default/shadowsocks-libev by the maintainer scripts

#
# This is a POSIX shell fragment
#
# Note: `START', `GROUP' and `MAXFD' options are not recognized by systemd.
# Please change those settings in the corresponding systemd unit file.

# Enable during startup?
START=yes

# Configuration file
CONFFILE="/etc/shadowsocks-libev/config.json"

# Extra command line arguments
DAEMON_ARGS="-u"

# User and group to run the server as
USER=nobody
GROUP=nobody

# Number of maximum file descriptors
MAXFD=32768

5. Add service script

New File /lib/systemd/system/shadowsocks-libev.service
Add the following code into the file

#  This file is part of shadowsocks-libev.
#
#  Shadowsocks-libev is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.
#
#  This file is default for Debian packaging. See also
#  /etc/default/shadowsocks-libev for environment variables.

[Unit]
Description=Shadowsocks-libev Default Server Service
Documentation=man:shadowsocks-libev(8)
After=network.target

[Service]
Type=simple
EnvironmentFile=/etc/default/shadowsocks-libev
User=nobody
Group=nobody
LimitNOFILE=32768
ExecStart=/usr/local/bin/ss-server -c $CONFFILE $DAEMON_ARGS

[Install]
WantedBy=multi-user.target

6. Command

Start: systemctl start shadowsocks-libev
Stop: systemctl stop shadowsocks-libev
Restart: systemctl restart shadowsocks-libev
View Status: systemctl status shadowsocks-libev -f
boot: systemctl enable shadowsocks-libev
Cancellation boot:systemctl disable shadowsocks-libev

Guess you like

Origin www.cnblogs.com/kujisa/p/11529593.html