Welcome to nginx!

安装

1、准备编译环境

yum -y install libxml2 libxml2-devel libxslt-devel gd-devel gperftools libuuid-devel libblkid-devel libudev-devel fuse-devel libedit-devel libatomic_ops-devel gcc-c++

以及安装 libmaxminddb(如不启用 GeoIP2 模块可以忽略)

2、下载并解压

由于 GeoIP 官方已不再支持,如果要支持最新 GeoIP2 ,需要添加ngx_http_geoip2_module。下载 GeoIP2 模块

git clone https://github.com/leev/ngx_http_geoip2_module.git

下载,解压

wget https://nginx.org/download/nginx-1.16.0.tar.gz
tar -xvf nginx-1.16.0.tar.gz
cd nginx-1.16.0

3、配置并构建 Nginx

./configure \
--prefix=/usr/local \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib64/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module \
--with-http_image_filter_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-mail \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-stream \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-google_perftools_module \
--with-cpp_test_module \
--with-compat \
--with-pcre \
--with-pcre-jit \
--with-libatomic \
--with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' \
--add-dynamic-module=../ngx_http_geoip2_module
make
sudo make install

查看 Nginx 是否安装成功

nginx -v

nginx version: nginx/1.16.0

4、创建 nginx 用户

groupadd nginx
useradd -g nginx nginx

5、创建 nginx cache 文件夹

mkdir /var/cache/nginx

6、配置 nginx.service

sudo vi /usr/lib/systemd/system/nginx.service

复制粘贴:

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target

7、启用 GeoIP2 模块(可选)

编辑 /etc/nginx/nginx.conf 文件

在 events 之前加入:

load_module /usr/lib64/nginx/modules/ngx_http_geoip2_module.so;

在 http 内加入以下代码:

#/usr/share/GeoIP/GeoIP2-Country.mmdb 替换为实际路径
geoip2 /usr/share/GeoIP/GeoIP2-Country.mmdb {
    auto_reload 60m;
    $geoip2_metadata_country_build metadata build_epoch;
    $geoip2_data_country_code country iso_code;
    $geoip2_data_country_name country names en;
}

#/usr/share/GeoIP/GeoIP2-City.mmdb 替换为实际路径
geoip2 /usr/share/GeoIP/GeoIP2-City.mmdb {
    auto_reload 60m;
    $geoip2_data_city_name city names en;
}

fastcgi_param COUNTRY_CODE $geoip2_data_country_code;
fastcgi_param COUNTRY_NAME $geoip2_data_country_name;
fastcgi_param CITY_NAME    $geoip2_data_city_name;

8、启动 nginx 服务

systemctl start nginx
systemctl enable nginx

解决 error: the HTTP XSLT module requires the libxml2/libxslt 错误

yum -y install libxml2 libxml2-dev
yum -y install libxslt-devel

解决 error: the HTTP image filter module requires the GD library. 错误

yum -y install gd-devel

解决 error: the GeoIP module requires the GeoIP library. 错误

yum -y install GeoIP GeoIP-devel GeoIP-data

解决 error: the Google perftools module requires the Google perftools 错误

yum -y install gperftools

解决 error: libatomic_ops library was not found. 错误

yum -y install libuuid-devel libblkid-devel libudev-devel fuse-devel libedit-devel libatomic_ops-devel

解决 error trying to exec 'cc1plus': execvp: No such file or directory 错误

yum -y install gcc-c++

解决 error: [pool www] cannot get uid for user 'www-data' 错误

groupadd www-data
useradd -g www-data www-data

解决configure: error: mbed TLS libraries not found. 错误。

需要安装mbedtls,教程:https://www.24kplus.com/linux/281.html

解决 error: Cannot find OpenSSL's <evp.h> 错误

yum install openssl openssl-devel
ln -s /usr/lib64/libssl.so /usr/lib/

解决 error: Libtool library used but 'LIBTOOL' is undefined 错误

yum install libtool

解决 exec: g++: not found 错误

yum -y update gcc
yum -y install gcc+ gcc-c++

解决 configure: error: tss lib not found: libtspi.so 错误

yum install trousers-devel

解决 Can't exec "autopoint": No such file or directory 错误

yum install gettext gettext-devel gettext-common-devel

解决 configure: error: libcrypto not found. 错误

yum remove openssl-devel
yum -y install openssl-devel

解决 configure: error: Package requirements (libffi >= 3.0.0) were not met: No package 'libffi' found 错误

yum install libffi-devel

解决 fatal error: uuid.h: No such file or directory 错误

yum install e2fsprogs-devel uuid-devel libuuid-devel

解决 configure: error: openssl lib not found: libcrypto.so 错误

yum install openssl-devel

解决 tar (child): lbzip2: Cannot exec: No such file or directory 错误

yum -y install bzip2

解决 configure: error: C++ preprocessor "/lib/cpp" fails sanity check 错误

yum install gcc-c++

解决 configure: error: Please reinstall the BZip2 distribution 错误

yum install bzip2 bzip2-devel

解决 configure: error: cURL version 7.15.5 or later is required to compile php with cURL support 错误

yum install curl-devel

解决 configure: error: not found. Please provide a path to MagickWand-config or Wand-config program 错误

yum install ImageMagick-devel

解决 configure: error: no acceptable C compiler found in $PATH 错误

yum install gcc

解决 configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met: 错误

yum install libicu-devel

解决 configure: error: Package requirements (sqlite3 > 3.7.4) were not met: No package 'sqlite3' found 错误

yum install sqlite-devel

解决 configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found 错误

yum install oniguruma oniguruma-devel

注意:.NET Core仅支持64位系统。

1、添加 dotnet repos

在安装.NET之前,需要注册 Microsoft key,注册 repos 并安装所需的依赖项。

打开 terminal 并运行以下命令:

sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm

2、 安装 .NET SDK

在 terminal 中,运行以下命令:

sudo yum update
sudo yum install dotnet-sdk-2.2

官方英文原文:https://dotnet.microsoft.com/download/linux-package-manager/centos/sdk-current

Ubuntu 16.04 或更高版本安装 .NET Core SDK,需要注意的是.NET Core仅支持 16.04 或更高版本的 64位系统。

1、注册 Microsoft key和 repos

在安装.NET之前,需要注册 Microsoft key,注册 repos 并安装所需的依赖项。

打开 terminal 并运行以下命令:

wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

2、 安装 .NET SDK

在 terminal 中,运行以下命令:

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

如果出现Unable to locate package dotnet-sdk-2.2错误,运行以下命令:

sudo dpkg --purge packages-microsoft-prod && sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

如果还没有安装成功,可以尝试以下命令运行手动安装:

sudo apt-get install -y gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/ubuntu/18.04/prod.list
sudo mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
sudo chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
sudo chown root:root /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get install -y apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2

官方英文原文:https://dotnet.microsoft.com/download/linux-package-manager/ubuntu18-04/sdk-current

前言

HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer 或 Hypertext Transfer Protocol Secure,超文本传输安全协议),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。

申请免费ssl证书的方式有很多,这里就不再多说。

1、在站点配置 server { } 中加入以下代码

#监听ssl默认端口443
#ipv4
listen 443 ssl;
#如果支持ipv6
listen [::]:443 ssl;
	
#注意:这里24kplus.com替换成你的证书名字
ssl_certificate  ssl/24kplus.com.pem;
ssl_certificate_key ssl/24kplus.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

2、重启ningx

systemctl restart nginx

启用ssl就这么简单!

nginx https

免费SSL证书申请直达航班:

阿里云 https://cn.aliyun.com/product/cas

前言

Deluge是一个功能齐全的跨平台BitTorrent 客户端软件,可在Linux, OS X, Unix和Windows操作系统下工作。它使用libtorrent作为其后端,有包括GTK+,网络远程客户端,命令行模式等多种用户界面。其设计方针是体积小巧且节约系统资源,通过丰富的插件来实现核心以外的众多功能。Deluge响应Freedesktop.org的倡议,兼容于GNOME, KDE, XFCE和其它多种桌面环境。它还是一款自由软件,使用GPLv3进行授权。

1、安装 deluge

sudo apt-get install deluge

2、安装 deluge web 管理面板

sudo apt-get install deluged deluge-web deluge-console

deluge 的安装目录在 /usr/lib/python2.7/dist-packages/deluge

如果出现add-apt-repository: command not found错误,执行:

sudo apt-get install python-software-properties

3、创建 deluged.service 配置文件

sudo vi /etc/systemd/system/deluged.service

复制粘贴:

[Unit]
Description=Deluge Bittorrent Client Daemon
Documentation=man:deluged
After=network-online.target
[Service]
Type=simple
User=root
ExecStart=/usr/bin/deluged -d
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/deluged
Restart=on-failure
TimeoutStopSec=300
[Install]
WantedBy=multi-user.target

4、创建 deluge-web.service 配置文件

sudo vi /etc/systemd/system/deluge-web.service

复制粘贴:

[Unit]
Description=Deluge Bittorrent Client Web Interface
Documentation=man:deluge-web
After=network-online.target deluged.service
Wants=deluged.service
[Service]
Type=simple
User=root
ExecStart=/usr/bin/deluge-web
ExecStop=/usr/bin/kill /usr/bin/deluge-web
Restart=on-failure
[Install]
WantedBy=multi-user.target

5、启动 deluged 和 deluge-web 服务,并设置自启动

sudo systemctl start deluged
sudo systemctl enable deluged

sudo systemctl start deluge-web
sudo systemctl enable deluge-web

6、开启远程访问(可选)

deluge-web默认只允许本地访问。默认端口:8112,默认密码:deluge

#启用远程访问
deluge-console "config -s allow_remote True"

#禁用远程访问
deluge-console "config allow_remote"

访问地址:http://你的公网IP:8112

deluge web

到此,deluge 客户端配置基本完成。

deluge 官方网站:https://www.deluge-torrent.org/

解决configure: error: The Sodium crypto library libraries not found.错误。

1、下载并解压

wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable.tar.gz
tar -zxf libsodium-1.0.18-stable.tar.gz
cd libsodium-stable

备用下载地址:https://down.24kplus.com/linux/libsodium-1.0.18-stable.tar.gz

2、编译安装

./configure --prefix=/usr
make && make check
sudo make install
sudo ldconfig

如出现以下错误:

config.status: error: Something went wrong bootstrapping makefile fragments
     for automatic dependency tracking.  Try re-running configure with the
     '--disable-dependency-tracking' option to at least be able to build
     the package (albeit without support for automatic dependency tracking). 

执行:

yum install make -y

更多错误解决方案:https://www.24kplus.com/linux/400.html

1、先安装yum-utils

yum install yum-utils -y

2、设置yum repos

创建文件/etc/yum.repos.d/nginx.repo

sudo vi /etc/yum.repos.d/nginx.repo

复制粘贴:

[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

默认情况下,安装稳定版(stable)nginx,如果要安装主线版本(mainline) nginx包,请运行以下命令:

sudo yum-config-manager --enable nginx-mainline

3、安装nginx

sudo yum install nginx -y

查看nginx版本

nginx -v

nginx version: nginx/1.16.0

3、启动 nginx

#启动
systemctl start nginx
#检查状态
systemctl status nginx
#设置自启动
systemctl enable nginx

到此,Nginx安装结束。

官方英文原文:http://nginx.org/en/linux_packages.html#RHEL-CentOS

CentOS 7/8 源码安装 mbedtls 2.16.3, 解决configure: error: mbed TLS libraries not found. 错误。

1、下载并解压

wget https://tls.mbed.org/download/mbedtls-2.16.3-gpl.tgz
tar -xf mbedtls-2.16.3-gpl.tgz
cd mbedtls-2.16.3

备用下载地址:https://down.24kplus.com/linux/mbedtls/mbedtls-2.16.3-gpl.tgz

2、编译安装

make
make DESTDIR=/usr install
ldconfig

如果出现 make[1]: python2: Command not found 错误,执行:

yum -y install python2

如果出现 /usr/bin/env: ‘perl’: No such file or directory 错误,执行:

yum -y install perl

CentOS 安装 shadowsocks-libev, 本教程仅提供学习,请勿用于商业用途和不法行为。

如果你觉得安装步骤繁杂,可以试试 一键安装 shadowsocks-libev

1、准备编译环境

CentOS 7

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

CentOS 8

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

2、获取shadowsocks-libev源码, 并安装

yum install git
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
git submodule update --init
./autogen.sh && ./configure --disable-documentation && make
sudo make install

如果出现 error: The Sodium crypto library libraries not found 错误,安装 libsodium

如果出现 error: mbed TLS libraries not found. 错误,安装 mbedtls

3、 创建配置文件

sudo mkdir /etc/shadowsocks-libev
sudo vi /etc/shadowsocks-libev/config.json

复制粘贴如下内容(注意修改密码“password”):

{
     "server":"0.0.0.0",
     "server_port":8388,
     "local_port":1080,
     "password":"password",
     "timeout":600,
     "method":"aes-256-cfb" ,
     "fast_open": false
 }

4、创建Shadowsocks-libev.service配置文件

sudo vi /etc/systemd/system/shadowsocks-libev.service

复制粘贴:

[Unit]
Description=Shadowsocks-libev Server
Documentation=https://shadowsocks.org/en/
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ss-server -c /etc/shadowsocks-libev/config.json -u
Restart=on-abort

[Install]
WantedBy=multi-user.target

5、启动 Shadowsocks-libev 服务

sudo systemctl start shadowsocks-libev

6、设置开机启动

sudo systemctl enable shadowsocks-libev

至此, Shadowsocks-libev服务器端的基本配置已经全部完成了!

设置防火墙开放端口

开放 tcp/udp 8388 端口

firewall-cmd --zone=public --add-port=8388/tcp --permanent
firewall-cmd --zone=public --add-port=8388/udp --permanent

重新载入防火墙配置,使规则生效

sudo systemctl restart firewalld

优化 Shadowsocks-libev 直达航班: 优化 shadowsocks-libev 网络

最后送上Windows 客户端 Shadowsocks-4.1.7.1.zip