2017年11月

在 CentOS 7 里安装 tomcat 7 openjdk 1.8 nginx mysql 5.6

yum update
yum install java-1.8.0-openjdk
yum install tomcat
yum install nginx

            proxy_pass         http://127.0.0.1:8080; 
            proxy_redirect     off;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

echo 0 >/proc/sys/net/ipv6/conf/all/disable_ipv6
echo 0 >/proc/sys/net/ipv6/conf/default/disable_ipv6

ifconfig sit0 up
ifconfig sit0 inet6 tunnel ::66.220.18.42
ifconfig sit1 up
ifconfig sit1 inet6 add ::2/64
route -A inet6 add ::/0 dev sit1

nohup ping6 ipv6.google.com >/dev/null 2>&1 &

在 Ubuntu 16.04 里安装 FastDFS 5.11 - 单台服务器

环境:Ubuntu 16.04 64位,FastDFS 5.11,nginx 1.12,本例服务器IP:172.16.252.32

过程:

  1. apt-get update # 更新软件仓库
  2. apt-get install git # 安装 git 工具,等会复制 libfastcommon
  3. git clone https://github.com/happyfish100/libfastcommon.git # 复制 libfastcommon 源码到本地
  4. ./make.sh # 解压,并进入到 libfastcommon 的目录里,编译
  5. ./make.sh install # 安装
  6. ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so # 创建符号链接
  7. wget https://github.com/happyfish100/fastdfs/archive/V5.11.tar.gz # 下载 fastdfs 5.11版本
  8. ./make.sh # 解压,并进入到 fastdfs 的目录里,编译
  9. ./make.sh install # 安装
  10. cp /etc/fdts/client.conf.sample /etc/fdts/client.conf # 创建 client.conf 配置文件,同理,创建好 storage.conf 和 tracker.conf
  11. adduser fastdts # 创建普通用户 fastdts ,上传的文件将主要存储在这 /home/fastdts
  12. 修改 tracker.conf 配置文件里的 base_path 参数,如本例 base_path=/home/fastdfs
  13. 修改 storage.conf 配置文件里的base_path, store_path0, tracker_server 参数,如本例 base_path=/home/fastdfs , store_path0=/home/fastdfs , tracker_server=172.16.252.32:22122
  14. 修改 client.conf 配置文件里的 base_path 和 tracker_server 参数,如本例 base_path=/home/fastdfs , tracker_server=172.16.252.32:22122
  15. 在FastDFS软件包里conf目录里的 http.conf mime.types 复制到 /etc/fdts/ ,且在 client.conf 配置文件里引用 http.conf 的文件(将“##include http.conf”修改成“#include http.conf”)
  16. /etc/init.d/fdfs_trackerd start # 启动 trackerd 进程
  17. /etc/init.d/fdfs_storaged start # 启动 storaged 进程
  18. fdfs_test /etc/fdfs/client.conf upload /root/ali_10.png # 在服务器本地上传图片测试,得到远程文件名:M00/00/00/rBD8IFoeip-AXBnkAAJuOBgfXyE450.png
  19. wget http://nginx.org/download/nginx-1.12.2.tar.gz # 下载 nginx 源码包
  20. apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev # 准备好编译环境
  21. git clone https://github.com/happyfish100/fastdfs-nginx-module # 复制 fastdfs-nginx-module 的源码文件,假如保存在 /usr/local/fastdfs-nginx-module
  22. ./configure --prefix=/usr/local/nginx --add-module=/usr/local/fastdfs-nginx-module/src/ # 解压后,到nginx的目录中的配置
  23. make # 编译
  24. make install # 安装 nginx
  25. vi /usr/local/nginx/conf/nginx.conf # 修改 nginx 的站点配置内容,如下:

    location /M00 {
    root /home/fastdfs/data;
    ngx_fastdfs_module;
    }
  26. ln -s /home/fastdfs/data /home/fastdfs/data/M00 # 创建 M00 的符号链接
  27. cp /usr/local/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdts # 复制 mod_fastdfs.conf 配置文件
  28. vi /etc/fdts/mod_fastdfs.conf 配置文件里的 tracker_server 和 store_path0 值,如本例 tracker_server=172.16.252.32:22122, store_path0=/home/fastdfs
  29. /usr/local/nginx/sbin/nginx # 启动 nginx
  30. 在浏览器里访问测试,可以显示上传的文件内容,如 http://swas.anqun.org/M00/00/00/rBD8IFoeip-AXBnkAAJuOBgfXyE450.png

参考:

在 Debian 8 系统里安装 jupyter notebook

环境:Debian 8

过程:

  1. Debian 8 默认的 python 版本是2.7,按 jupyter notebook 的安装建议,先安装 python3.6:

    wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
    tar xzvf Python-3.6.3.tgz
    cd Python-3.6.3
    ./configure
    make
    make install
  2. 新建一个普通用户,如liujia,登录后将python3.6加到bash配置文件中:
    echo 'alias python="/usr/local/bin/python3.6"' >> ~/.bashrc
  3. 下载 Anaconda3,安装:
    wget https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
    bash ./Anaconda3-5.0.1-Linux-x86_64.sh
  4. 安装好后,将 Anaconda3 路径加到 bash 配置文件中:
    export PATH=/home/liujia/anaconda3/bin:$PATH
    source ~/.bashrc
  5. 运行 jupyter notebook
    jupyter notebook --no-browser --ip=0.0.0.0
  6. 默认 jupyter notebook 使用 8888 端口,如需通过 80 端口访问,可安装 nginx 后使用 proxy_pass 代理访问

参考:

在RequestTracker(RT)里用msmtp通过远程smtp服务器465端口发邮件

SoftLayer(IBM Cloud)过滤了TCP 25端口,Vultr的也可能过滤了,越来越多的云服务商主动屏蔽了25端口的通讯。

阿里云对新建的ECS实例,也过滤了25端口。

RequestTracker的工单系统,邮件通知是重要的需求之一,当阿里云ECS实例不能使用25端口发信时,可以尝试配置msmtp使用远程的smtp 465端口来发邮件。

环境:Deiban 8,RT 4.4.2, RT安装在 /opt/rt4 的路径
国内某免费的企业邮箱:smtp服务器地址,smtp.exmail.qq.com;SSL端口:465;邮箱地址:rt@anqun.org

过程:

  1. /opt/rt4/etc/msmtp_wrapper.conf # 在RT配置目录中创建 msmtp 的配置文件,文件属主是web进程用户,即www-data,权限是600,内容如下:

    defaults
    port 465
    tls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    # logfile ~/.msmtp.log
    
    account qmail
    host smtp.exmail.qq.com
    from rt@anqun.org
    auth on
    user rt@anqun.org
    password NiDeMiMa
    # auto_from on
    tls_starttls off
    
    # Set a default account
    account default : qmail
  2. /opt/rt4/etc/msmtp_wrapper # 在RT文件配置目录中创建Shell文件,文件属性是web进程用户,即www-data,且有执行的权限,+x,内容如下:

    /usr/bin/msmtp -t -C /opt/rt4/etc/msmtp_wrapper.conf
    /usr/bin/logger -t RTmailer -p syslog.info -- CALL /usr/bin/msmtp -nt "$@" RETURNED $?
  3. /opt/rt4/etc/RT_SiteConfig.pm # 在RT的自定义配置文件中,加入以下一行内容,让RT使用msmtp来发信:

    Set( $SendmailPath, '/opt/rt4/etc/msmtp_wrapper');

  4. 重启Web服务,以让新的设置生效,测试发信正常

参考:

手动校验SSL证书私匙和证书是否匹配

一般我们申请免费证书时,如阿里云的单域名证书,是自动生成CSR文件,不需自行创建,审核通过后,会收到证书文件(.crt 或 .pem)和私匙文件(*.key)。

如选择自行生成CSR文件(一般同时还会生成.key文件),提交给机构审核认证后,会获取到证书文件。

问题:apache 启动时提示私匙和证书不匹配。

[Thu Nov 16 21:24:39.816853 2017] [ssl:emerg] [pid 11120] AH02238: Unable to configure RSA server private key
[Thu Nov 16 21:24:39.816868 2017] [ssl:emerg] [pid 11120] SSL Library Error: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch

过程:

  1. openssl x509 -noout -text -in /etc/pki/tls/certs/localhost.crt -modulus # 验证证书文件,记下 modulus 的值
  2. openssl rsa -noout -text -in /etc/pki/tls/private/localhost.key -modulus # 验证私匙文件,记下 modulus 的值
  3. 对比两者的值,如果相符就可以了

参考: