nginx負載均衡一些配置的實戰演示!
(1)解壓nginx:

(2)解壓openssl:

(3)解壓pcre:

(4)解壓zlib:


(5)進行配置,先進入到nginx里面去,然后執行下面語句:

./configure --prefix=/usr/local/nginx
--with-http_realip_module
--with-http_addition_module
--with-http_gzip_static_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-stream
--with-pcre=/home/txp/share/nginx/pcre-8.41
--with-zlib=/home/txp/share/nginx/zlib-1.2.11
--with-openssl=/home/txp/share/nginx/openssl-1.1.0g
然后直接make:

然后接著再sudo make install:

最終我們可以看到在/usr/local/nginx/目錄下看到安裝的nginx:

現在我們可以試著來運行nginx,并進行訪問(下面的訪問成功):


這里小結一下:
很多開源軟件的安裝步驟大概都差不多是下面這樣的套路(比如等下我們下面要安裝的模塊,也是這樣安裝的思路,所以這里就不造輪子了)
-- ./cofigure
-- make
--sudo make install
2、自己寫conf文件
在平時的開發過程中,主要我們要去配置它的conf文件夾下的nginx.conf文件
root@ubuntu:/usr/local/nginx# ls
client_body_temp conf fastcgi_temp
html logs proxy_temp sbin scgi_temp
uwsgi_temp
這個文件原本內容是:
#user nobody;
worker_processes 1;
#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 koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
請輸入評論內容...
請輸入評論/評論長度6~500個字


分享













