首先,登录ubuntu系统
首先需安装nginx依赖库
1.安装gcc g++的依赖库
apt-get install build-essential apt-get install libtool
2.安装pcre依赖库
sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev
3.安装zlib依赖库
apt-get install zlib1g-dev
4.安装ssl依赖库
apt-get install openssl
安装nginx
#下载最新版本: wget http://nginx.org/download/nginx-1.11.3.tar.gz #解压: tar -zxvf nginx-1.11.3.tar.gz #进入解压目录: cd nginx-1.11.3 #配置: ./configure --prefix=/usr/local/nginx #编辑nginx: make 注意:这里可能会报错,提示“pcre.h No such file or directory”,具体详见:http://stackoverflow.com/questions/22555561/error-building-fatal-error-pcre-h-no-such-file-or-directory 需要安装 libpcre3-dev,命令为:sudo apt-get install libpcre3-dev #安装nginx: sudo make install #启动nginx: sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 注意:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过 -h查看帮助命令。 #查看nginx进程: ps -ef|grep nginx
配置nginx
cd /usr/local/nginx/conf/
使用vim或nano编辑器在该目录下新建一个ihasy.conf文件输入以下内容:
upstream ihasy { server 127.0.0.1:9001; #Tornado } ## Start www.ihasy.com ## server { listen 80; server_name www.ihasy.com ihasy.com; #root html; #index index.html index.htm index.py index; ## send request back to Tornado ## location / { proxy_pass http://ihasy; #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } } ## End www.ihasy.com ##
再使用vim或nano打开 /usr/local/nginx/conf/nginx.conf
nano /usr/local/nginx/conf/nginx.conf
在http下添加一行
include ihasy.conf
保存,重启nginx,即可实现反向代理。
上传文件大小设置
client_max_body_size 属性设置
location ~ [^/].php(/|$) { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; client_max_body_size 500m; }