liunx 安装tengine服务器
安装依赖
yum -y install wget zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc
下载tengine 编译
wget -c http://tengine.taobao.org/download/tengine-2.1.2.tar.gz ./configure make sudo make install
开机自启动nginx
vi /etc/init.d/nginx (输入下面的代码)
#!/bin/bash # nginx Startup script for the Nginx HTTP Server # it is v.0.0.2 version. # chkconfig: - 85 15 # description: Nginx is a high-performance web and proxy server. # It has a lot of features, but it's not for everyone. # processname: nginx # pidfile: /var/run/nginx.pid # config: /usr/local/nginx/conf/nginx.conf nginxd=/usr/local/nginx/sbin/nginx nginx_config=/usr/local/nginx/conf/nginx.conf nginx_pid=/var/run/nginx.pid RETVAL=0 prog="nginx" # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 [ -x $nginxd ] || exit 0 # Start nginx daemons functions. start() { if [ -e $nginx_pid ];then echo "nginx already running...." exit 1 fi echo -n $"Starting $prog: " daemon $nginxd -c ${nginx_config} RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx return $RETVAL } # Stop nginx daemons functions. stop() { echo -n $"Stopping $prog: " killproc $nginxd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid } # reload nginx service functions. reload() { echo -n $"Reloading $prog: " #kill -HUP `cat ${nginx_pid}` killproc $nginxd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; reload) reload ;; restart) stop start ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|reload|status|help}" exit 1 esac exit $RETVAL:wq 保存并退出
设置文件的访问权限
chmod a+x /etc/init.d/nginx (a+x ==> all user can execute 所有用户可执行)
同样的修改了nginx的配置文件nginx.conf,也可以使用上面的命令重新加载新的配置文件并运行,可以将此命令加入到rc.local文件中,这样开机的时候nginx就默认启动了
vi /etc/rc.local
加入一行 /etc/init.d/nginx start 保存并退出,下次重启会生效。
启动后 需要 在防火墙里添加80端,或者直接关闭防火墙
标签: 服务器
免费SSL证书 Let’s Encrypt 安装方法
现在国内https已经在蔓延,今天把博客换成了https了 地址栏 变绿了!
个人站点大部分用的是免费的,国内景安申请的WoSign SSL可以用一年,或者国外的 Let’s Encrypt ,本站用的就是 Let’s Encrypt 。
具体流程可以参考 这篇文章
https://www.baidufe.com/item/ed5324e20e555d938ca8.html
使用 写好的website-ssl.sh
但是在我安装的时候遇到几个问题
1、服务器的 python 版本是否高于2.6 不然会报
Traceback (most recent call last): File "acme_tiny.py", line 2, in <module> import argparse, subprocess, json, os, sys, base64, binascii, time, hashlib, re, copy, textwrap, logging ImportError: No module named argparse这个时候你就要升级你的PYTHON 升级看谷歌,建议不要直接覆盖原来版本,并且编译完成后 不要覆盖 /usr/bin/python链接,可以先加一个 比如python3,因为系统很多地方使用的python还是2 ;如果不是覆盖新加的链接 需要在website-ssl.sh 文件的 # 申请证书crt文件 下一行 python 换成python3
2、# CA认证 转向配置错误
ValueError: Wrote file to /home/xxx/www/challenges/oJbvpIhkwkBGBAQUklWJXyC8VbWAdQqlgpwUJkgC1Vg, but couldn't download http://www.yoursite.com/.well-known/acme-challenge/oJbvpIhkwkBGBAQUklWJXyC8VbWAdQqlgpwUJkgC1Vg
这个时候就要需要检查你的网站的nginx配置内是否加入了
# CA认证 location ^~ /.well-known/acme-challenge/ { #你自己的challenges目录 alias /www/work/challenges/; try_files $uri =404; }
3.域名DNS CAA验证出错
上面的问题都解决了,但是又出现了
'error': {'detail': 'DNS problem: query timed out looking up CAA for , 'status': 400, 'type': 'urn:acme:error:connection'}, 'type': 'http-01'}这个时候你只能换一个DNS服务器了,这里推荐CloudXNS的免费DNS,
4、防火墙开启443端口
然后按照上面那篇文章执行 都没有错 但是依然无无法打开https的网站 的时候请看看你的防火墙是不是开启了443 端口
标签: 服务器