从零开始在linux上搭建web服务器

ubuntu 是自带python2.7的,如果要使用python3.x,可以直接安装对应的版本,千万不要卸载以前的版本,因为其他库的运行需要借助python2.7

让linux 在tab时对大小写不敏感

bind "set completion-ignore-case on"

 

1. 安装python3.5

sudo apt-get install python3.5

2. 安装pip3.5

sudo apt-get install python3-pip

安装后到目录/usr/local/lib/

3. 安装nginx

sudo apt-get install nginx

nginx -h #帮助  

nginx -v #显示版本  

nginx -V #显示版本和配置信息  

nginx -t #测试配置  

nginx -q #测试配置时,只输出错误信息  

nginx -s stop #停止服务器  

nginx -s reload #重新加载配置  

4. 配置https

生成证书

可以通过以下步骤生成一个简单的证书:
首先,进入你想创建证书和私钥的目录,例如:

cd /etc/nginx/ssl.conf

 

创建服务器私钥,命令会让你输入一个口令:

openssl genrsa -des3 -out server.key 1024

 

创建签名请求的证书(CSR):

openssl req -new -key server.key -out server.csr

 

在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:

cp server.key server.key.org
openssl rsa -in server.key.org -out server.key

 

配置nginx

最后标记证书使用上述私钥和CSR:

openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

 

修改Nginx配置文件,让其包含新标记的证书和私钥:

server {
    server_name YOUR_DOMAINNAME_HERE;
    listen 443;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/server.key;
}

 

 

posted @ 2017-05-26 17:52  在路上的少年  阅读(10198)  评论(0编辑  收藏  举报