目录
1. 购买域名,备案,购买服务器
2. 选择Linux版本,ubuntu16.04 64位
3. 更新系统
apt-get updateapt-get upgrade
4. 安装git
apt-get install git
若要使用git clone 需要ssh-keygen -t rsa -C "your email@mail.com"
拷贝.ssh目录中的pub内容到github的SSH keys中
5. 安装python(默认已经安装python2与python3),pip等,pip3有错误,需要修改,见另一篇文章。
6. 虚拟环境搭建virtualenv
7. 安装mysql
- 注意修改bind:127.0.0.1与权限分配
8. 关于uwsgi的安装与配置:
新建uwsgi.ini文件, 并配置
- https://www.cnblogs.com/wswang/p/5521566.html
- https://www.cnblogs.com/wongbingming/p/7106830.html
9. 安装nginx:
分为**源码**安装与**压缩包**稳定版安装,两者的文件安装目录不同 /etc/nginx/与/usr/local/nginx
新建 uc_nginx.conf文, 并配置
http://www.cnblogs.com/piscesLoveCc/p/5794926.html
https://www.jianshu.com/p/7cb1a824333e
https://blog.csdn.net/bestallen/article/details/52837609
10. 配置https证书
现在让我们使用 [Let's Encrypt](https://letsencrypt.org/)提供的一个很好的HTTPS证书来提高我们的应用程序的安全性。 设置HTTPS从未如此简单。更好的是,我们现在可以免费获得它。他们提供了一个名为**certbot**的解决方案 ,负责为我们安装和更新证书。这非常简单: ```shell sudo apt-get update sudo apt-get install software-properties-common sudo add-apt-repository ppa:certbot/certbot sudo apt-get update sudo apt-get install python-certbot-nginx ``` 现在安装证书: ```shell sudo certbot --nginx ``` 然后就好了,证书和私钥位置在 ```shell /etc/letsencrypt/live/www.example.com/privkey.pem ``` 只需按照提示操作即可。当被问及: ```tex Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. ``` 选择`2`将所有HTTP流量重定向到HTTPS。 证书是 90 天的,运行 ``` $ sudo certbot renew --dry-run ``` Certbot 会帮你启动一个定时任务,在证书过期时自动更新 PS:云服务器上的安全组规则里记得把 443 端口开了。
常用命令
查看端口占用:netstat -ntpl 查看进程:ps aux | grep nginx //查看nginx进程 查看端口占用情况:lsof -i:80 //查看80端口占用情况 杀死进程:kill -9 3274 //3274为进程PID Nginx安装:apt-get install nginx Nginx启动、停止和重启命令 /etc/init.d/nginx start /etc/init.d/nginx stop /etc/init.d/nginx reload Nginx压缩包安装版: Nginx启动、停止和重启命令 /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx -s stop /usr/local/nginx/sbin/nginx -s reload