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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

nginx python webpy 配置安装

發布時間:2023/12/13 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx python webpy 配置安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝webpy
$ wget http://webpy.org/static/web.py-0.34.tar.gz
$ tar xvzf web.py-0.34.tar.gz
$ cd web.py-0.34
$ sudo python setup.py install

安裝 Flup
http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
$ wget http://www.saddi.com/software/flup/dist/flup-1.0.2.tar.gz
$ tar xvzf flup-1.0.2.tar.gz
$ cd flup-1.0.2
$ sudo python setup.py install

安裝 Spawn-fcgi
wget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gz
tar zxvf spawn-fcgi-1.6.3.tar.gz
cd spawn-fcgi-1.6.3
./configure --prefix=/usr設置到/usr

make && make install # install

python2.7
=========================
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar jxvf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure
make && make install

安裝mysql-for-python2.7

http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/
yum install python-devel
yum install mysql-devel
修改mysqldb目錄下site.cfg文件,確保mysql_config選項路徑配置正確
python setup.py build
python setup.py install
有問題可以看下載目錄下的安裝要求中的項目,或FAQ
http://mysql-python.sourceforge.net/FAQ.html

.安裝 pcre 讓nginx支持rewrite

? ? ?pcre-8.10.tar.gz? 上傳到/home 目錄下面

? ? 1) 解壓?pcre

? ? ?tar zxvf ??pcre-8.10.tar.gz 解壓?pcre 后 /home 下面會有?pcre-8.10 文件夾

? ? ?2)配置pcre

? ? ?cd /home/?pcre-8.10

? ? ./configure --prefix=/usr/local/pcre-7.8 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
???? configure有許多參數可配,具體參見./configure --help及手冊

? ? ?3)make

? ? ?在linux 中輸入 make 命令后屏幕會生成一堆文件,不用去管它

? ? ?4)安裝

? ? ??在linux 中輸入 make?install

--進行一些文件拷貝,下一步安裝nginx需要指定路徑
[root@]# mkdir /usr/include/pcre
[root@]# cp /usr/local/lib/libpcre.a /usr/include/pcre/libpcre.a
[root@]# cp /usr/local/lib/libpcre.la /usr/include/pcre/libpcre.la
[root@]# cp /usr/local/include/pcre.h /usr/include/pcre/pcre.h
[root@]# mkdir /usr/include/pcre/.libs
[root@]# cp /usr/local/lib/libpcre.a /usr/include/pcre/.libs/libpcre.a
[root@]# cp /usr/local/lib/libpcre.la /usr/include/pcre/.libs/libpcre.la
[root@]# cp /usr/local/include/pcre.h /usr/include/pcre/.libs/pcre.h


安裝Nginx
源碼包可以在官方主頁上下載。Ubuntu 7.10可以直接通過apt安裝,也可以從這里下載最新的deb包:
sudo apt-get install nginx
如果要自己編譯的話,需要確保自己已經有編譯器和PCRE的庫(用于Nginx的rewrite模塊,如果不需要這個模塊可以在configure時使用./configure –without-rewrite)。

編譯方法如下:
wget http://sysoev.ru/nginx/nginx-0.5.34.tar.gz
tar zxvf nginx-0.5.34.tar.gz
cd nginx-0.5.34
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make && make install # install要求有root權限

?cd ?/usr/local/nginx/sbin

? ? ? ? ?./nginx -t?

? ? ? ? ?結果顯示:

? ? ? ??nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

? ? ? ? nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

? ? ? ?6)啟動nginx?

? ? ? ? ? cd ?/usr/local/nginx/sbin 目錄下面 輸入 ./nginx 啟動 nginx


Nginx 配置文件



? server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?localhost;
? ? ? ? #access_log ?logs/host.access.log ?main;
? ? ? ? location / {
? ? ? ? ? ? root ? html;
? ? ? ? ?fastcgi_param REQUEST_METHOD $request_method;
? ? ? ? fastcgi_param QUERY_STRING $query_string;
? ? ? ? fastcgi_param CONTENT_TYPE $content_type;
? ? ? ? fastcgi_param CONTENT_LENGTH $content_length;
? ? ? ? fastcgi_param GATEWAY_INTERFACE CGI/1.1;
? ? ? ? fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
? ? ? ? fastcgi_param REMOTE_ADDR $remote_addr;
? ? ? ? fastcgi_param REMOTE_PORT $remote_port;
? ? ? ? fastcgi_param SERVER_ADDR $server_addr;
? ? ? ? fastcgi_param SERVER_PORT $server_port;
? ? ? ? fastcgi_param SERVER_NAME $server_name;
? ? ? ? fastcgi_param SERVER_PROTOCOL $server_protocol;
? ? ? ? fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
? ? ? ? fastcgi_param PATH_INFO $fastcgi_script_name;
? ? ? ? fastcgi_pass 127.0.0.1:9001;
? ? ? ? index ?index.html index.htm code.py;
? ? ? ? }
對于靜態文件可以添加如下配置:

location /static/ {
??? if (-f $request_filename) {
??? rewrite ^/static/(.*)$? /static/$1 break;
??? }
}

重啟nginx配置:
/path/to/nginx/sbin/nginx -s reload

停止nginx:
/path/to/nginx/sbin/nginx -s stop

Spawn-fcgi

可以通過一下命令啟動一個Spawn-fcgi進程:


spawn-fcgi -d ~/nginx-dir/html -f ./code.py -a 127.0.0.1 -p 9002 -F 2?-P /tmp/webpy.pid

將進程PID保存下來方便關閉進程:

kill `cat /tmp/webpy.pid`

參數說明:

-f 指定調用 FastCGI 的進程的執行程序位置,根據系統上所裝的 PHP 的情況具體設置
-a 綁定到地址 addr
-p 綁定到端口 port
-F 指定產生的 FastCGI 的進程數? (很多人以為是-C,其實那是PHP專用的,這里要用-F)
-P 指定產生的進程的 PID 文件路徑
-u 和 -g FastCGI 使用什么身份運行

?

如果運行Spawn-fcgi之后,ps -ef 不能發現進程,sudo netstat -antup不能發現端口說明Spawn-fcgi沒有正常啟動,可以在啟動參數中加 -n 之后再啟動會有詳細信息.問題也就找到了.

總結

以上是生活随笔為你收集整理的nginx python webpy 配置安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。