yum install -y zsh
yum install -y git
wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
useradd www -d /home/www -m -s /bin/zsh
passwd www
pip install virtualenv
pip install flask
yum -y update
cd /home/www
virtualenv venv
source venv/bin/activate
pip install flask
vim hello.py
#coding=utf-8
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return "Hello There!
"
if __name__ == '__main__':
app.run()
source /home/www/venv/bin/activate
pip install gunicorn
gunicorn hello:app
netstat -an | grep 80
yum install nginx
systemctl enable nginx
systemctl start nginx
激活nginx和启动nginx
测试nginx是否安装成功,去浏览器输入阿里云公ip,看网页输出结果
添加nginx配置文件,新版本打开nginx默认配置文件,在里面添加如下内容
vim /etc/nginx/nginx.conf
server {
listen 80;
server_name 47.90.99.88;
root /home/www;
access_log /home/www/logs/nginx_access.log;
error_log /home/www/logs/nginx_error.log;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
nginx -t -c /etc/nginx/nginx.conf
nginx -s reload
pip install supervisor
echo_supervisord_conf > /etc/supervisord.conf
[include]
files = /etc/supervisor/conf.d/*.conf
[program:www]
command=/home/www/venv/bin/gunicorn hello:app
directory=/home/www/
user=root
autostart=true
autorestart=true
stdout_logfile=/home/www/logs/supervisor_out.log
stderr_logfile=/home/www/logs/supervisor_err.log
supervisorctl reread
supervisorctl update
supervisorctl restart www
pip freeze > requirements.txt
pip install -r requirements.txt
pip uninstall urllib3 && pip uninstall requests && pip uninstall chardet && pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3
error: , [Errno 2] No such file or directory: file: /usr/lib64/python2.7/socket.py line: 224
解决办法
supervisord
certbot证书过期后如何更新证书并生效
certbot renew
nginx -s reload
certbot证书过期后报错解决办法:https://certbot.eff.org/docs/install.html
wget https://dl.eff.org/certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
sudo chown root /usr/local/bin/certbot-auto
sudo chmod 0755 /usr/local/bin/certbot-auto
/usr/local/bin/certbot-auto --help
/usr/local/bin/certbot-auto --install-only
/opt/eff.org/certbot/venv/bin/certbot