欢迎来到梦飞科技

服务器租用

当前优惠活动:

利用nginx设置负载平衡基本教程

需要的预置情况:

1.openssl-fips-2.0.5.tar.gz 

2.pcre-8.32.tar.gz 

3.zlib-1.2.7.tar.gz

4.nginx-1.2.6.tar.gz

1)root用户mkdir目次/usr/local/nginx/

2)将这4个包安排在该目次下,并tar -zxvf *.tar.gz解压

3)安装openssl-fips-2.0.5,

3.1)cd /usr/local/nginx/openssl-fips-2.0.5/

3.2)./config

3.3)make

3.4)make install

4)安装pcre-8.32和zlib-1.2.7用*取代

4.1)cd /usr/local/nginx/*/

4.2)./configure

4.3)make

4.4)make install

5)安装nginx-1.2.6

5.1)cd /usr/local/nginx/nginx-1.2.6/

5.2)

./configure --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.7 --with-openssl=../openssl-fips-2.0.5

5.3)make

5.4)make install

6)检测下安装是否乐成

操作nginx配置负载均衡根基教程

这种环境暗示是对的。

然后查察一下/usr/local/nginx/conf/nginx.conf,主要想看看端标语,

在/usr/local/nginx/conf/路径下有一个nginx.conf.default,其实我是用的这个,“原生态”的这个文件如下,

#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
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_timeout  5m;
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

可以看到,端标语listen 80,因此,我测试下会见http://210.10.5.189:80/,5.189就是这台陈设nginx处事的linux红帽6

操作nginx配置负载均衡根基教程

所以陈设是正确的。

其实这里的页面是目次/usr/local/nginx/html下面的,所以默认的状态静态页面都是在此目次下

操作nginx配置负载均衡根基教程

梦飞科技 - 全球数据中心基础服务领先供应商

Copyright © 2003-2019 MFISP.COM. 国外服务器租用 IDC公司 版权所有 粤ICP备11019662号