日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

网站部署nginx--uwsgi

發(fā)布時間:2024/7/5 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 网站部署nginx--uwsgi 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

網(wǎng)站代碼寫完之后就是項目部署,主要包括兩個方面:


1.nginx安裝與配置:

1、Nginx 安裝

系統(tǒng)平臺:CentOS release 6.6 (Final) 64位。

一、安裝編譯工具及庫文件

yum -y install make zlib zlib-devel gcc-c++ libtool ?openssl openssl-devel

二、首先要安裝 PCRE

PCRE 作用是讓 Nginx 支持 Rewrite 功能。

1、下載 PCRE 安裝包,下載地址:?http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

[root@bogon?src]# wget?http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

2、解壓安裝包:

[root@bogon?src]# tar zxvf pcre-8.35.tar.gz

3、進(jìn)入安裝包目錄

[root@bogon?src]# cd pcre-8.35

4、編譯安裝?

[root@bogon?pcre-8.35]# ./configure [root@bogon?pcre-8.35]# make?&& make install

5、查看pcre版本

[root@bogon?pcre-8.35]# pcre-config --version

安裝 Nginx

1、下載 Nginx,下載地址:http://nginx.org/download/nginx-1.6.2.tar.gz

[root@bogon?src]# wget?http://nginx.org/download/nginx-1.6.2.tar.gz

2、解壓安裝包

[root@bogon?src]# tar zxvf nginx-1.6.2.tar.gz

3、進(jìn)入安裝包目錄

[root@bogon?src]# cd nginx-1.6.2

4、編譯安裝

[root@bogon?nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35 [root@bogon?nginx-1.6.2]# make [root@bogon?nginx-1.6.2]# make install

5、查看nginx版本

[root@bogon?nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v

到此,nginx安裝完成。


2.nginx配置:

首先,進(jìn)入文件 cd /usr/local/nginx/conf/nginx.conf 編輯帶入如下:


#user nobody; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024; }http {include mime.types;default_type application/octet-stream;#log_format main '$remote_addr - $remote_user [$time_local] "$request" '# '$status $body_bytes_sent "$http_referer" '# '"$http_user_agent" "$http_x_forwarded_for"';#access_log logs/access.log main;sendfile on;#tcp_nopush on;#keepalive_timeout 0;keepalive_timeout 65;#gzip on;server {listen 80;server_name www.itcast.cn;#charset koi8-r;#access_log logs/host.access.log main;# location / { # root html; # index index.html index.htm; # } #根目錄,注意html文件location / {root /var/www/ihome/static/html;index index.html;} #uwsgi配置iplocation /api {uwsgi_pass 127.0.0.1:5000;include uwsgi_params;} #靜態(tài)文件配置,靜態(tài)文件需要遷移到此文件下location /static {alias /var/www/ihome/static;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {# proxy_pass http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {# root html;# fastcgi_pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;# include fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {# deny all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {# listen 8000;# listen somename:8080;# server_name somename alias another.alias;# location / {# root html;# index index.html index.htm;# }#}# HTTPS server##server {# listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certificate_key cert.key;# ssl_session_cache shared:SSL:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:!MD5;# ssl_prefer_server_ciphers on;# location / {# root html;# index index.html index.htm;# }#}}
注:需要拷貝static文件 ?:cp -r static /var/www/ihome/static

配置好uwsgi后啟動nginx:sudo sbin/nginx

如需停止:sudo sbin/nginx -s stop


2.uwsgi文件創(chuàng)建與配置


1.進(jìn)入虛擬環(huán)境:workon 虛擬環(huán)境名稱

2.創(chuàng)建文件:touch uwsgi.ini

3.編輯文件:

[uwsgi] #按照實際情況改動,這里只是舉例 # uwsgi 啟動時所使用的地址與端口 socket = 127.0.0.1:8001pidfile = uwsgi.pid daemonize = uwsgi.log # 指向網(wǎng)站目錄 chdir = /home/python/Desktop/ihome/test4# python 啟動程序文件 wsgi-file = test4.py# python 程序內(nèi)用以啟動的 application 變量名 callable = app# 處理器數(shù) processes = 4# 線程數(shù) threads = 2#每次修改代碼自動reload,無需要手動重啟 #py-autoreload = 1#狀態(tài)檢測地址 stats = 127.0.0.1:9001
4.啟動uwsgi: ? uwsgi ?--ini uwsgi.ini

5.啟動nginx

如需關(guān)閉uwsgi: ?uwsgi ?--stop uwsgi.pid



總結(jié)

以上是生活随笔為你收集整理的网站部署nginx--uwsgi的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。