Nginx部署
下载安装包:
| 1 | wget --no-check-certificate https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/get/master.tar.gz | 
解压安装包:
| 1 | tar -zxvf master.tar.gz | 
安装环境(逐条):
| 1 | yum -y install gcc-c++ autoconf automake | 
修改配置文件(一整块复制):
| 1 | ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --add-module=/opt/tmp/nginx-sticky/ | 
验证:进入NGINX的安装目录-执行完成后输入echo $?验证,返回值为0表示执行成功
安装:
| 1 | cd nginx-1.12.2 | 
配置:
| 1 | vim conf/nginx.conf | 
修改如下内容:
| 1 | service { | 
:wq 保存退出vim
查看是否成功:
在浏览器输入服务器IP ,查看是否有Nginx的欢迎页面,若访问不成功,检查阿里云/腾讯云是否开启80端口。
相关指令:
| 1 | /usr/local/nginx/sbin/nginx //启动 | 
安装Python3
下载:
| 1 | wget https://www.Python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz | 
解压:
| 1 | tar xJf Python-3.6.1.tar.xz | 
进入 python-3.6.1 目录:
| 1 | cd Python-3.6.1 | 
安装:
| 1 | ./configure --prefix=/usr/local/python3 && make && make install | 
创建软连接:
| 1 | ln -s /usr/local/python3/bin/python3 /usr/bin/python3 | 
virtualenv(Python 虚拟机)
用来区分python环境
安装:
| 1 | pip3 install virtualenv | 
创建虚拟环境:
| 1 | /usr/local/python3/bin/virtualenv -p /usr/bin/python3 venv | 
相关指令:
| 1 | source venv/bin/activate //激活 | 
Tornado (Python web service框架)
- GET & POST
示例代码:
| 1 | # -*- coding:utf-8 -*- | 
supervisor
- python 虚拟环境保活1 vim /etc/supervisord.conf 在末尾增加:1 
 2
 3
 4[program:xxx] 
 command= venv/bin/python3 WebService/TornadoWS.py
 autorestart=true
 user=rootwq保存退出 ``` 1 
 2
 3
 4
 ### 执行:
 ```bash
 supervisorctl relod
- supervisor更多指令:
supervisorctl status 查看supervisor状态
supervisorctl start xxx 开启xxx进程
supervisorctl stop xxx 停止xxx进程
supervisorctl 进入supervisor控制台