- 首先需安装nginx依赖库
apt-get install build-essential
apt-get install libtool
- 安装pcre依赖库
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
- 安装zlib依赖库
apt-get install zlib1g-dev
- 安装ssl依赖库
apt-get install openssl
- nginx download url
- tar -zxvf nginx-1.12.2.tar.gz
- cd nginx-1.12.2
- ./configure --prefix=/usr/local/nginx
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"
bingo=_=
- make
- sudo make install
- (qidong start)sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- (view process) ps -ef|grep nginx
/home/jackray/Public/soft/nginx-1.12.2# ps -ef|grep nginx
root 13803 1178 0 18:59 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 13804 13803 0 18:59 ? 00:00:00 nginx: worker process
root 13806 1910 0 18:59 pts/0 00:00:00 grep --color=auto nginx
- cd /usr/local/nginx/conf/ start to config
- touch ihasy.conf
- view
/nginx/conf# ls ihasy.conf
ihasy.conf
- vim ihasy.conf insert the context like follows
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 ##
- shift + : wq! enter ~bingo
- /usr/local/nginx/conf# vim nginx.conf
- 在http下添加一行
http {
include ihasy.conf;
- pkill -9 nginx
view the ubuntu’s version
how to config nginx for ubuntu