1、準備環境node
檢查python版本以及pip版本python
[root@linux-node01 src]# python --version Python 2.7.5 [root@linux-node01 src]# pip --version pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7) [root@linux-node01 src]#
若是沒有安裝pipmysql
在安裝了epel源的狀況下,直接yum就能夠安裝python3.4linux
yum install python34 -y
python3 --version
沒有自帶pip3,從官網安裝nginx
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py # 執行下載 python3 get-pip.py # 改成 python get_pip.py便可安裝
pip3 -V
2、安裝nginxc++
1. openresty簡介web
openresty是一個nginx套件,而非fork,這表示 :
openresty沒有修改nginx源碼,這和Tengine等項目不一樣。
openresty是給原生的nginx增長了不少功能插件,例如:支持lua腳本,支持在nginx配置文件中獲取post參數,支持lua腳本鏈接mysql和redis等
openresty中的nginx是較新版,但不必定是最新版
openresty的官網是:
https://openresty.org/cn/
2. 安裝步驟redis
#安裝依賴的軟件包 yum install -y readline-devel ncurses-libs pcre-devel perl make postgresql-devel geoip-devel libdrizzle-devel geoip-devel yum -y install gcc gcc-c++ 下載最新版openresty wget https://openresty.org/download/openresty-1.11.2.1.tar.gz # 解壓它 tar zxvf openresty-1.11.2.1
3. 配置openrestysql
./configure --conf-path=/etc/openresty/openresty.conf \ --error-log-path=/var/log/openresty/error.log \ --http-client-body-temp-path=/var/lib/openresty/body \ --http-fastcgi-temp-path=/var/lib/openresty/fastcgi \ --http-log-path=/var/log/openresty/access.log \ --http-proxy-temp-path=/var/lib/openresty/proxy \ --lock-path=/var/lock/openresty.lock --pid-path=/var/run/openresty.pid \ --with-debug --with-http_dav_module --with-http_flv_module \ --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module\ --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module \ --with-ipv6 --with-mail --with-mail_ssl_module --prefix=/usr/local/openresty \ --with-luajit --with-http_postgres_module --with-http_iconv_module
若是想用nginx鏈接mysql,須要在配置命令最後添加
--with-http_drizzle_module
4. 編譯安裝bootstrap
待配置過程完成之後 gmake gmake install 創建必要的工做目錄 mkdir /var/lib/openresty; mkdir /var/lib/openresty/body; 創建軟連接,方便調用 ln -s /usr/local/openresty/nginx/sbin/nginx /usr/bin/nginx
5. 報錯信息
安裝pcre objs/addon/src/ngx_http_lua_regex.o: In function `ngx_http_lua_regex_free_study_data': /opt/openresty-1.11.2.1/build/nginx-1.11.2/../ngx_lua-0.10.6/src/ngx_http_lua_regex.c:1959: undefined reference to `pcre_free_study' objs/addon/src/ngx_http_lua_regex.o: In function `ngx_http_lua_ffi_destroy_regex': /opt/openresty-1.11.2.1/build/nginx-1.11.2/../ngx_lua-0.10.6/src/ngx_http_lua_regex.c:2353: undefined reference to `pcre_free_study' collect2: ld 返回 1 gmake[2]: *** [objs/nginx] 錯誤 1 gmake[2]: Leaving directory `/opt/openresty-1.11.2.1/build/nginx-1.11.2' gmake[1]: *** [build] 錯誤 2 gmake[1]: Leaving directory `/opt/openresty-1.11.2.1/build/nginx-1.11.2' gmake: *** [all] 錯誤 2 說明當前系統中的pcre沒法使用,須要本身下載,下載地址 https://sourceforge.net/projects/pcre/files/pcre/8.39/ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz tar zxvf pcre-8.39.tar.gz 在配置openresty時添加以下配置 --with-pcre=../pcre-8.39
6. 檢查配置
# 過濾生成nginx配置文件 [root@linux-node01 src]# grep -Ev "^$|#" /etc/openresty/openresty.conf >/etc/openresty/nginx.conf # 檢查配置文件 [root@linux-node01 src]# /usr/local/openresty/nginx/sbin/nginx -t nginx: the configuration file /etc/openresty/openresty.conf syntax is ok nginx: configuration file /etc/openresty/openresty.conf test is successful [root@linux-node01 src]# /usr/local/openresty/nginx/sbin/nginx -c /etc/openresty/nginx.conf -t nginx: the configuration file /etc/openresty/nginx.conf syntax is ok nginx: configuration file /etc/openresty/nginx.conf test is successful [root@linux-node01 src]#
7. 啓動服務:8080端口
[root@linux-node01 src]# /usr/local/openresty/nginx/sbin/nginx -c /etc/openresty/nginx.conf [root@linux-node01 src]# [root@linux-node01 src]# netstat -lnpt |grep 80 tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 3605/nginx: master tcp6 0 0 :::80 :::* LISTEN 1390/httpd You have new mail in /var/spool/mail/root [root@linux-node01 src]#
3、安裝uwsgi
1. 操做命令
pip install uwsgi
2. 檢查安裝
[root@linux-node01 openresty]# uwsgi --version 2.0.17 [root@linux-node01 openresty]#
3. 建立uwsgi配置文件
[root@linux-node01 openresty]# cat /etc/uwsgi9090.cnf [uwsgi] socket = 127.0.0.1:9090 master = true //主進程 vhost = true //多站模式 no-site = true //多站模式時不設置入口模塊和文件 workers = 2 //子進程數 reload-mercy = 10 vacuum = true //退出、重啓時清理文件 max-requests = 1000 limit-as = 512 buffer-size = 30000 pidfile = /var/run/uwsgi9090.pid //pid文件,用於下面的腳本啓動、中止該進程 daemonize = /website/uwsgi9090.log [root@linux-node01 openresty]#
4. 設置完成後,在終端運行