Nginx1.10.1安装配置

一、 Ngix依赖模块安装
Ngix依赖模块有:pcre、zlib、openssl、md5 /sha1(如果系统中没有安装相应模块,需要按照下列方式安装)
1、 安装pcre模块(8.35)
官方网站:http://www.pcre.org/
安装命令:

unzip pcre-8.35.zip

cd pcre-8.35

./configure

make && make install

 在64位linux系统中,nginx搜索的库位置为lib64;所以,需要建立软连接:

# ln -s /usr/local/lib/libpcre.so.1 /lib64/

ln -s /usr/local/lib/libpcre.so.1 /lib/

ln -s /usr/local/lib/libpcre.so.1 /usr/local/lib64/

2、 安装zlib模块(1.2.8)
官方网站:http://www.zlib.net/
安装命令:

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure

make && make install

3、 安装openssl模块(1.0.1h)
官方网站:http://www.openssl.org/
安装命令:

tar zxvf openssl-1.0.1h.tar.gz

cd openssl-1.0.1h

./config

make &&make install

二、 Nginx安装
1、 安装Nginx(1.10.1)
官方网站:http://nginx.org/
安装命令:

tar zxvf nginx-1.10.1.tar.gz

cd nginx-1.10.1

./configure –prefix=/etc/nginx \
–sbin-path=/usr/sbin/nginx \
–conf-path=/etc/nginx/nginx.conf \
–error-log-path=/var/log/nginx/error.log \
–http-log-path=/var/log/nginx/access.log \
–pid-path=/var/run/nginx.pid \
–lock-path=/var/run/nginx.lock \
–http-client-body-temp-path=/var/cache/nginx/client_temp \
–http-proxy-temp-path=/var/cache/nginx/proxy_temp \
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
–http-scgi-temp-path=/var/cache/nginx/scgi_temp \
–user=airbook \
–group=airbook \
–with-openssl=/home/airbook/bk/depends/openssl-1.0.1h \
–with-http_ssl_module \
–with-http_realip_module \
–with-http_addition_module \
–with-http_sub_module \
–with-http_dav_module \
–with-http_flv_module \
–with-http_mp4_module \
–with-http_gunzip_module \
–with-http_gzip_static_module \
–with-http_random_index_module \
–with-http_secure_link_module \
–with-http_stub_status_module \
–with-http_auth_request_module \
–with-threads \
–with-stream \
–with-stream_ssl_module \
–with-http_slice_module \
–with-mail \
–with-mail_ssl_module \
–with-file-aio \
–with-http_v2_module \
–with-ipv6”

2、Nginx配置
nginx.conf修改配置如下:
user airbook airbook;
worker_processes 5;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;

#size limits
client_max_body_size           50m;
client_body_buffer_size        256k;
client_header_timeout          3m;
client_body_timeout            3m;
send_timeout                   3m;

sendfile        on;
tcp_nopush      on;
keepalive_timeout  120;
tcp_nodelay on;

#跨域
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

include              vhosts/upstream.conf;
include              vhosts/h5.conf;

}

upstream.conf配置如下:
server {
listen 9090;
server_name api_airbook;
location / {
root html;
index index.html index.htm;
proxy_pass http://ab_api;
}
}
upstream ab_api {
ip_hash;
server 10.23.19.48:9090 max_fails=2 fail_timeout=30s;
}

h5.conf配置如下:
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

}

3、nginx常用命令
A、 启动命令
#nginx
B、 停止命令
# -s stop
C、 检查配置文件
# nginx -t -c /usr/local/nginx/conf/nginx.conf

你可能感兴趣的:(OP)