方法一、如果你知道要删除软件的具体名称,可以使用

sudo apt-get remove --purge 软件名称
sudo apt-get autoremove --purge 软件名称

方法二、如果不知道要删除软件的具体名称,可以使用

dpkg --get-selections | grep ‘软件相关名称’

sudo apt-get purge 一个带core的package,如果没有带core的package,则是情况而定。

清理残留数据

dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

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

namespace Utility.Security
{
    /// <summary>
    /// RSA加密解密
    /// </summary>
    public class RSAUtil
    {
        /// <summary>
        /// RSA加密
        /// </summary>
        /// <param name="str">需要加密的字符串</param>
        /// <param name="encryptKey">密钥</param>
        /// <returns>加密后的字符串</returns>
        public static string RSAEncrypt(string str, string encryptKey)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(str);
            byte[] privKeyBytes = Convert.FromBase64String(encryptKey);
            AsymmetricKeyParameter asymmetricKeyParameter = PrivateKeyFactory.CreateKey(privKeyBytes);
            IAsymmetricBlockCipher signer = new Pkcs1Encoding(new RsaEngine());
            signer.Init(true, asymmetricKeyParameter);
            //加密
            byte[] encryptBytes = signer.ProcessBlock(bytes, 0, bytes.Length);
            string rsaString = Convert.ToBase64String(encryptBytes);
            return rsaString;
        }

        /// <summary>
        /// RSA解密
        /// </summary>
        /// <param name="str">需要解密的字符串</param>
        /// <param name="decryptKey">密钥</param>
        /// <returns>解密后的字符串</returns>
        public static string RSADecrypt(string str, string decryptKey)
        {
            byte[] strBytes = Convert.FromBase64String(str);
            byte[] keyBytes = Convert.FromBase64String(decryptKey);
            AsymmetricKeyParameter asymmetricKeyParameter = PublicKeyFactory.CreateKey(keyBytes);
            IAsymmetricBlockCipher signer = new Pkcs1Encoding(new RsaEngine());
            signer.Init(false, asymmetricKeyParameter);
            byte[] decryptedBytes = signer.ProcessBlock(strBytes, 0, strBytes.Length);
            string decryptString = Encoding.UTF8.GetString(decryptedBytes);
            return decryptString;
        }
    }
}

解决 Linq 的 lambda 表达式排序不够灵活问题。

namespace Utility.Linq
{
    public static class QueryableExtend
    {
        /// <summary>
        /// 根据键按升序对序列的元素排序
        /// </summary>
        /// <typeparam name="TSource">source 中的元素的类型</typeparam>
        /// <param name="source">一个要排序的值序列</param>
        /// <param name="field">排序字段</param>
        /// <returns>一个 System.Linq.IOrderedQueryable T,根据键对其元素排序。</returns>
        public static IQueryable<TSource> OrderBy<TSource>(this IQueryable<TSource> source, string field)
        {
            source = source.OrderBy(field, "OrderBy");
            return source;
        }

        /// <summary>
        /// 根据键按降序对序列的元素排序
        /// </summary>
        /// <typeparam name="TSource">source 中的元素的类型</typeparam>
        /// <param name="source">一个要排序的值序列</param>
        /// <param name="field">排序字段</param>
        /// <returns>一个 System.Linq.IOrderedQueryable T,根据键对其元素排序。</returns>
        public static IQueryable<TSource> OrderByDescending<TSource>(this IQueryable<TSource> source, string field)
        {
            source = source.OrderBy(field, "OrderByDescending");
            return source;
        }

        /// <summary>
        /// 根据某个键按降序对序列中的元素执行后续排序。
        /// </summary>
        /// <typeparam name="TSource">source 中的元素的类型</typeparam>
        /// <param name="source">一个要排序的值序列</param>
        /// <param name="field">排序字段</param>
        /// <param name="isDescending">是否倒序(可选,默认否)</param>
        /// <returns>一个 System.Linq.IOrderedQueryable T,根据键对其元素排序。</returns>
        public static IQueryable<TSource> ThenBy<TSource>(this IQueryable<TSource> source, string field)
        {
            source = source.OrderBy(field, "ThenBy");
            return source;
        }

        /// <summary>
        /// 使用指定的比较器按降序对序列中的元素执行后续排序。
        /// </summary>
        /// <typeparam name="TSource">source 中的元素的类型</typeparam>
        /// <param name="source">一个要排序的值序列</param>
        /// <param name="field">排序字段</param>
        /// <param name="isDescending">是否倒序(可选,默认否)</param>
        /// <returns>一个 System.Linq.IOrderedQueryable T,根据键对其元素排序。</returns>
        public static IQueryable<TSource> ThenByDescending<TSource>(this IQueryable<TSource> source, string field)
        {
            source = source.OrderBy(field, "ThenByDescending");
            return source;
        }

        /// <summary>
        /// 根据键按升序对序列的元素排序
        /// </summary>
        /// <typeparam name="TSource">source 中的元素的类型</typeparam>
        /// <param name="source">一个要排序的值序列</param>
        /// <param name="field">排序字段</param>
        /// <param name="methodName">排序方法名</param>
        /// <returns>一个 System.Linq.IOrderedQueryable T,根据键对其元素排序。</returns>
        public static IQueryable<TSource> OrderBy<TSource>(this IQueryable<TSource> source, string field, string methodName)
        {
            if(source == null)
            {
                throw new ArgumentException("source");
            }
            if(field == null)
            {
                throw new ArgumentException("field");
            }
            if(methodName == null)
            {
                throw new ArgumentException("methodName");
            }
            Type entityType = typeof(TSource);
            ParameterExpression parameterExpression = Expression.Parameter(entityType, entityType.FullName);
            Expression propertyExpression = Expression.Property(parameterExpression, entityType.GetProperty(field));
            Expression expression = Expression.Lambda(propertyExpression, parameterExpression);
            PropertyInfo propertyInfo = entityType.GetProperty(field);
            Type propertyType = propertyInfo.PropertyType;
            Expression expr = Expression.Call(typeof(Queryable), methodName, new Type[] { entityType, propertyType }, source.Expression, expression);
            source = source.Provider.CreateQuery<TSource>(expr);
            return source;
        }
    }
}

注意:.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

扩展jquery.fn,增加获取或设置zIndex的function

/*扩展 jQuery.fn 的方法*/
jQuery.fn.extend({
    /*
    获取或设置zIndex
    */
    zIndex: function (zIndex) {
        if (zIndex !== undefined) {
            return this.css("zIndex", zIndex);
        }
        if (this.length) {
            var elem = $(this[0]), position, value;
            while (elem.length && elem[0] !== document) {
                // Ignore z-index if position is set to a value where z-index is ignored by the browser
                // This makes behavior of this function consistent across browsers
                // WebKit always returns auto if the element is positioned
                position = elem.css("position");
                if (position === "absolute" || position === "relative" || position === "fixed") {
                    // IE returns 0 when zIndex is not specified
                    // other browsers return a string
                    // we ignore the case of nested elements with an explicit value of 0
                    // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
                    value = parseInt(elem.css("zIndex"), 10);
                    if (!isNaN(value) && value !== 0) {
                        return value;
                    }
                }
                elem = elem.parent();
            }
        }
        return 0;
    }
});

if (jQuery.datepicker) {
    jQuery.datepicker.setDefaults({
        dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
        dayNamesShort: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
        dayNames: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
        monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
        monthNamesShort: ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'],
        weekHeader: '周',
        nextText: '下月&#x3e',
        prevText: '&#x3c上月',
        closeText: '完成',
        currentText: '今天',
        yearSuffix: '年'
    });
}