1. 程式人生 > >nginx安裝和配置

nginx安裝和配置

clu remote list server bin get 6.2 pro stub

安裝參照:http://www.runoob.com/linux/nginx-install-setup.html

配置參照:https://www.cnblogs.com/Miss-mickey/p/6734831.html

個人總結:

安裝:

1. nginx 前置安裝 prce

wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
[root@bogon src]# tar zxvf pcre-8.35.tar.gz
[root@bogon src]# cd pcre-8.35
[root@bogon pcre-8.35]# ./configure
[root@bogon pcre-8.35]# make && make install

[root@bogon pcre-8.35]# pcre-config --version

2. nginx 安裝:

[root@bogon src]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
[root@bogon src]# cd nginx-1.6.2

[root@bogon nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35
[root@bogon nginx-1.6.2]# make
[root@bogon nginx-1.6.2]# make install
[root@bogon nginx-1.6.2]# /usr/local/webserver/nginx/sbin/nginx -v

nginx 常用命令:

F:\>cd F:\develop\server\nginx 啟動 F:\develop\server\nginx>nginx -s reload 重啟 F:\develop\server\nginx>nginx -s stop 停止

配置:

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; #設定負載均衡的服務器列表 upstream mysvr { #weigth參數表示權值,權值越高被分配到的幾率越大 #本機上的Squid開啟3128端口 server 127.0.0.1:8888 weight=5; #server 192.168.8.2:80 weight=1; #server 192.168.8.3:80 weight=6; } #gzip on; server { listen 9980; server_name localhost; client_max_body_size 6m; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } location ~* /test { proxy_pass http://mysvr; }



 

nginx安裝和配置