一. 安装最新版本
webpy0.40 Flup
命令分别是:
sudo pip3 install web.py==0.40-dev1
sudo pip3 install flup
Spawn-fcgi的安装流程:
1.下载最新的安装包
2.tar xzvf spawn-fcgi-1.6.4.tar.gz
3.cd spawn-fcgi-1.6.4
4../configure
5.make && sudo make install
二. Nginx安装
查看ubuntu的位数:uname -a
查看ubuntu的版本:lsb_release -a 或者 cat /proc/version
我使用的环境是64位 Ubuntu 16.04。nginx依赖以下模块:
gzip模块需要 zlib 库
rewrite模块需要 pcre 库
ssl 功能需要openssl库
1.1.安装pcre
1. 获取pcre编译安装包,在http://www.pcre.org/上可以获取当前最新的版本
2. tar xzvf pcre-8.42.tar.gz
3. cd pcre-8.42,执行./configure
4. make & sudo make install
1.2.安装openssl
1. 获取openssl编译安装包,在http://www.openssl.org/source/上可以获取当前最新的版本。
2. 解压缩openssl-xx.tar.gz包。
3. 进入解压缩目录,执行./config
4. make & sudo make install
1.3.安装zlib
1. 获取zlib编译安装包,在http://www.zlib.net/上可以获取当前最新的版本。
2. 解压缩zlib-xx.tar.gz包。
3. 进入解压缩目录,执行./configure
4. make & sudo make install
1.4.安装nginx
1. 获取nginx,在http://nginx.org/en/download.html上可以获取当前最新的版本。
2. 解压缩nginx-xx.tar.gz包。
3. 进入解压缩目录,执行./configure
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module
4. make & sudo make install
nginx安装的基本信息:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
启动nginx:
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
,浏览器中输入http://localhost可以验证是否安装启动成功。
成功网页:
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
1、验证nginx配置文件是否正确
cd /usr/local/nginx/sbin
sudo ./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
说明配置文件正确!
方法二:在启动命令-c前加-t
sudo /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
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
2.Nginx基本操作:
启动nginx:
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
重启nginx配置:
sudo /usr/local/nginx/sbin/nginx -s reload
停止nginx:
sudo /usr/local/nginx/sbin/nginx -s stop
编辑文件:
sudo subl /usr/local/nginx/conf/nginx.conf
sudo subl /usr/local/nginx/logs/error.log
vim /usr/local/nginx/conf/nginx.conf
查看命令:
less, cat
因此不再建议大家使用以下方式(搜了一下,网上大量的文章,并且nginx.conf的默认配置也是使用这种方式):
include fastcgi_params;
而使用最新的方式,
include fastcgi.conf;
nginx 简单配置:
#user nobody;
worker_processes 2;
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 localhost;
charset utf8;
access_log logs/host.access.log main;
# root 此项目的根目录。
root C:/Users/RH-AS03/Desktop/GaoshengjieW/tasks/projects_statistics_3D;
# index 响应哪个网页到客户端。
index C:/Users/RH-AS03/Desktop/GaoshengjieW/tasks/projects_statistics_3D/templates/index.html C:/Users/RH-AS03/Desktop/GaoshengjieW/tasks/projects_statistics_3D/templates/index.htm;
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; # [1]
fastcgi_param PATH_INFO $fastcgi_script_name; # [2]
#此参数规定了的绑定地址:端口,
#使用spawn-fcgi方式启动一个程序:
# spawn-fcgi -d /path/to/www -f /path/to/www/index.py -a 127.0.0.1 -p 9002
fastcgi_pass 127.0.0.1:9002;
#root html;
#index index.html index.htm;
}
location /static/ {
if (-f $request_filename) {
rewrite ^/static/(.*)$ /static/$1 break;
}
}
#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;
# }
#}
}