成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

如何進(jìn)行Centos7.3x64安裝nginx與反向代理的應(yīng)用

如何進(jìn)行Centos 7.3 x64安裝nginx與反向代理的應(yīng)用,相信很多沒有經(jīng)驗(yàn)的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。

創(chuàng)新互聯(lián)是一家專業(yè)提供武義企業(yè)網(wǎng)站建設(shè),專注與成都做網(wǎng)站、成都網(wǎng)站建設(shè)、HTML5、小程序制作等業(yè)務(wù)。10年已為武義眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)的建站公司優(yōu)惠進(jìn)行中。

Centos 7.3 x64安裝nginx-1.13.1

一、安裝必要所需環(huán)境:

# yum install autoconf automake gcc gcc-c++ libtool make pkgconfig zlib-devel 

# yum install pcre pcre-devel php-devel httpd-devel

# yum install zlib zlib-devel  

# yum install openssl openssl-devel  

#  groupadd nginx

#  useradd -g nginx nginx

#  mkdir /software

#  cd /software

# wget http://nginx.org/download/nginx-1.13.1.tar.gz

# tar xzf nginx-1.13.1.tar.gz  

# cd nginx-1.13.1 

安裝相關(guān)依賴包

[root@ns1 nginx-1.13.1]#  yum install libxml2-devel libxslt-devel gd-devel

[root@ns1 nginx-1.13.1]#  yum install perl perl-devel perl-ExtUtils-Embed  libatomic_ops-devel

[root@ns1 nginx-1.13.1]# ./configure --user=nginx --group=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 --with-select_module --with-poll_module --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_p_w_picpath_filter_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_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-cpp_test_module  --with-cpu-opt=CPU --with-pcre  --with-pcre-jit  --with-zlib-asm=CPU --with-libatomic --with-debug --with-ld-opt="-Wl,-E" --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi

[root@ns1 nginx-1.13.1]# 

....成功結(jié)果如下

checking for atomic_ops library ... found

creating objs/Makefile

Configuration summary

  + using system PCRE library

  + using system OpenSSL library

  + using system zlib library

  + using system libatomic_ops library

  nginx path prefix: "/usr/local/nginx"

  nginx binary file: "/usr/sbin/nginx"

  nginx modules path: "/usr/local/nginx/modules"

  nginx configuration prefix: "/etc/nginx"

  nginx configuration file: "/etc/nginx/nginx.conf"

  nginx pid file: "/var/run/nginx.pid"

  nginx error log file: "/var/log/nginx/error.log"

  nginx http access log file: "/var/log/nginx/access.log"

  nginx http client request body temporary files: "/var/tmp/nginx/client/"

  nginx http proxy temporary files: "/var/tmp/nginx/proxy/"

  nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi/"

  nginx http uwsgi temporary files: "/var/tmp/nginx/uwsgi"

  nginx http scgi temporary files: "/var/tmp/nginx/scgi"

./configure: warning: the "--with-ipv6" option is deprecated

[root@ns1 nginx-1.13.1]# make

[root@ns1 nginx-1.13.1]# make install

[root@ns1 nginx-1.13.1]# nginx -V

nginx version: nginx/1.13.1

將啟動腳本(見附件)上傳到/etc/init.d/ 目錄下面

# chmod +x /etc/init.d/nginx 

# chkconfig --add nginx 

# chkconfig nginx on 

# chkconfig --list nginx 

# mkdir -p /var/tmp/nginx/client

編輯配置文件,紅色字體為修改或添加后的項(xiàng)目

# vi /etc/nginx/nginx.conf

user  root;

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       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;

    tcp_nopush      on;

    tcp_nodelay     on;

    types_hash_max_size 2048;

    client_max_body_size 20M;

    keepalive_timeout  65;

    gzip  on;

    gzip_disable "msie6";

    gzip_comp_level 6;

    gzip_min_length 1100;

    gzip_buffers 16 8k;

    gzip_proxied any;

    gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/rss+xml p_w_picpath/svg+xml;

    server {

        listen       80;

        server_name  110.110.220.54;

        charset utf-8;

        location / {

            root  /var/www/html/dongying;

            index  index.html index.htm index.jsp login.jsp;

        }

        #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 ssl;

    #    server_name  localhost;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;

    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers  on;

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

}

檢測配置文件是否有語法錯誤

[root@host-cn tmp]# nginx -t -c  /etc/nginx/nginx.conf

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

加入防火墻允許

[root@ns1 nginx]# firewall-cmd --add-service=http --permanent 

[root@ns1 nginx]# firewall-cmd --reload

[root@ns1 nginx]# systemctl restart firewalld

啟動nginx服務(wù)

[root@ns1 nginx]# service nginx start

再用戶就可以使用IP 110.110.220.54直接訪問網(wǎng)站了。

-----------------------------------------------------------------------------------

反向代理的應(yīng)用

公司同事,用tomcat發(fā)布了2個項(xiàng)目,可以用IP訪問他的項(xiàng)目

A項(xiàng)目地址  http://110.110.220.54:8080/dy/jsp/index.jsp

B項(xiàng)目地址  http://110.110.220.54:8080/dy/position/login.jsp

現(xiàn)在使用nginx,用公司域名www.dongying.com來發(fā)布他的項(xiàng)目,方法如下:

綠色部分為項(xiàng)目A,設(shè)定正常后用www.dongying.com來訪問。

橙色部分為項(xiàng)目B,設(shè)定正常后用www.dongying.com:8080/dy/position/login.jsp來訪問。

    server {

listen 80;

server_name www.dongying.com;

charset utf-8;

     location / {  

            proxy_pass http://www.dongying.com:8080/dgmy/jsp/;

            index index.html index.htm index.jsp login.jsp;

                 }

   location ~ \.(gif|jpg|jpeg|png|bmp|swf|css|js)$

                {

                   access_log off;

                   expires 1d;

                   root /opt/tomcat/webapps/dy/;

                    break;

            }

 location /dy/position/ {

            proxy_pass http://www.dongying.com:8080/dy/position/login.jsp;

            proxy_set_header           Host $host;

            proxy_set_header  X-Real-IP  $remote_addr;

            proxy_set_header           X-Forwarded-For $proxy_add_x_forwarded_for;

            client_max_body_size  100m;

            root   html;

            index  index.html index.htm index.jsp login.jsp;

       }

看完上述內(nèi)容,你們掌握如何進(jìn)行Centos 7.3 x64安裝nginx與反向代理的應(yīng)用的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

當(dāng)前標(biāo)題:如何進(jìn)行Centos7.3x64安裝nginx與反向代理的應(yīng)用
文章出自:http://jinyejixie.com/article20/iiecjo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站、網(wǎng)站設(shè)計網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、App設(shè)計、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
武城县| 上杭县| 晋州市| 抚州市| 五寨县| 崇左市| 茂名市| 富蕴县| 广灵县| 开平市| 富顺县| 吴忠市| 体育| 星座| 红桥区| 北流市| 大冶市| 泰来县| 宝坻区| 宜良县| 彭泽县| 新平| 社旗县| 长春市| 大名县| 岳阳县| 宁城县| 江孜县| 金山区| 苍溪县| 石家庄市| 潍坊市| 汽车| 靖宇县| 桂东县| 广安市| 噶尔县| 永仁县| 中西区| 宁都县| 鸡东县|