In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Nginx optimized compression configuration nginx [root@localhost ~] # yum install pcre-devel zlib-devel gcc gcc-c++-y # # installation environment package [root@localhost] # useradd-M-s / sbin/nologin nginx # # create a programmatic user [root@localhost] # mkdir / chen # # create a mount point [root@localhost] # mount.cifs / / 192.168.100.23/LNMP / chen # # mount Password for root@//192.168. 100.23/LNMP: [root@localhost chen] # tar zxvf nginx-1.12.2.tar.gz-C / opt/ # # extract [root@localhost chen] # cd / opt/ [root@localhost opt] # lsnginx-1.12.2 rh [root@localhost opt] # cd nginx-1.12.2/ [root@localhost nginx-1.12.2] # lsauto CHANGES.ru configure html man srcCHANGES conf contrib LICENSE README./configure\ # # install the nginx component-- prefix=/usr/local/nginx\-- user=nginx\-- group=nginx\-- with-http_stub_status_ module [root @ localhost nginx-1.12.2] # make & & make install # # compile [root@localhost nginx-1.12.2] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ # # make a soft link so that the system can recognize the nginx owner command [root@localhost nginx-1.12. 2] # nginx- t # # check syntax errors nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful write nginx script in system startup script to facilitate service manager to manage [root@localhost nginx-1.12.2] # cd / etc/init.d/ # # to system startup script [root@localhost init.d] # vim nginx # # write A nginx script #! / bin/bash#chkconfig:-99 20 # comment message # description: Nginx Service Control ScriptPROG= "/ usr/local/nginx/sbin/nginx" # this variable Point to my command file PIDF= "/ usr/local/nginx/logs/nginx.pid" # this variable, and point to the nginx process number case "$1" in start) $PROG ; stop) kill-s QUIT $(cat $PIDF);; restart) $0 stop $0 start;; reload) kill-s HUP $(cat $PIDF) *) echo "Usage: $0 {start | stop | restart | reload}" exit 1esacexit 0 [root@localhost init.d] # chmod + x nginx # # increase the authority of Nginx [root@localhost init.d] # chkconfig-- add nginx # # add nginx [root@localhost init.d] # service nginx start [root@localhost init. D] # netstat-ntap | grep nginx tcp 00 0.0.0.0 grep nginx tcp 80 0.0.0.0 LISTEN 17544/nginx: master [root@localhost init.d] # systemctl stop firewalld.service [root@localhost init.d] # setenforce 0nginx optimized compression configuration [root@localhost ~] # vim / usr/local/nginx/conf/nginx.confgzip on # # enable the compression feature gzip_min_length 1k; # # if you exceed 1kb, you will compress gzip_buffers 4 16k; # # cache space: 4 16kgzip_http_version 1.1; # # compressed version gzip_comp_level 6 # # Compression ratio, minimum is 1, processing speed is fast, transmission is slow, 9 maximum compression ratio, slow processing speed, fast transmission, moderate we choose 5 or 6gzip_types test/plain application/x-javascript text/css image/jpg image/jpeg image/png image/gif application/xml test/javascript application/x-httpd-php application/javascript application/json;## to support compression of gzip_disable "MSIE [1-6]\." # # configure to disable gzip conditions and support regularities. Do not enable gzipgzip_vary on below ie6 browsers # # compressed pages can be cached to the front-end server. Let's find an image to test the compression function [root@localhost] # cd / usr/local/nginx/html/ # # to the nginx site [root@localhost html] # ls50x.html index.html [root@localhost html] # mount.cifs / / 192.168.100.23/LNMP / mnt # # Mount Password for root@//192.168.100.23/LNMP: [root @ localhost html] # cd / mnt/ [root@localhost mnt] # lsDiscuz_X3.4_SC_UTF8.zip nginx-1.12.0.tar.gz php-7.1.20.tar.gzfang.png nginx-1.12.2.tar.gz shu.jpgmysql-boost-5.7.20.tar.gz php-7.1.10.tar.bz2 [root@localhost html] # cp / mnt/shu.jpg. / # to mount Directory [root@localhost html] # ls50x.html index.html shu.jpg [root@localhost html] # vim index.html # # to the site web page Write picture path 15
[root@localhost html] # service nginx stop # # disable nginx [root@localhost html] # service nginx start # # enable nginx [root@localhost html] # systemctl stop firewalld.service # # turn off the firewall [root@localhost html] # setenforce 0 # # close the enhanced Nginx optimized hotlink protection experimental environment, Nginx server, win10-1 as a test access, win10-2 as a hotlink URL, first make win10-2 a website and write a default web page The path of the image is the image of the hotlink Nginx.
Change the file extension to index.html
Win10-2 installs the website program
Open the website program, which is enabled by default
Put the page you just wrote into the site.
Go back to the Nginx server to install the DNS service and configure [root@localhost html] yum install bind-y # # install the DNS package [root@localhost html] # vim / etc/named.conf # # configure the main configuration file options {listen-on port 53 {any;}; # # listen on all addresses listen-on-v6 port 53 {:: 1;}; directory "/ var/named" Dump-file "/ var/named/data/cache_dump.db"; statistics-file "/ var/named/data/named_stats.txt"; memstatistics-file "/ var/named/data/named_mem_stats.txt"; recursing-file "/ var/named/data/named.recursing"; secroots-file "/ var/named/data/named.secroots"; allow-query {any;} # # allow everyone to access [root@localhost html] # vim / etc/named.rfc1912.zones # # configure zone profile zone "kgc.com" IN {type master; # # define kgc.com domain name file "kgc.com.zone"; # # define zone data profile allow-update {none;};} [root@localhost html] # cd / var/named/ [root@localhost named] # cp-p named.localhost kgc.com.zone # # copy the template to the created new zone data configuration file [root@localhost named] # vim kgc.com.zone # # Edit the data zone data configuration file $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.136.163 # # hostname, address [root@localhost named] # systemctl start named # # enable dns service win10-1 and win10-2 must choose DNS to resolve
Test Analysis of win10-2
Win10-1 to visit the website of win10-2
Access to the domain name or this picture
Go back to Nginx to configure hotlink protection [root@localhost named] # vim / usr/local/nginx/conf/nginx.conf 66 location ~ *\. (jpg | gif | swf) ${# # with 67 valid_referers none blocked * .kgc.com kgc.com with these image information ending in format # # if you parse locally, you will jump to the corresponding image 68 if ($invalid_referer) {# # if you do not parse locally, access 69 rewrite ^ / http://www.kgc.com/fang.png; # # via hotlink and jump the hotlink protection image to you 70} 71} [root@localhost html] # service nginx stop [root@localhost html] # service nginx start and then visit win10-1 for a test.
That's all we have. Thank you for watching.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.