In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
About Nginx, a high-performance, lightweight web service software
High stability
Low system resource consumption
High processing capacity for HTTP concurrent connections
A single physical server can support 30,000 to 50000 concurrent requests
Environment
One Linux server (192.168.13.128) and one win10 tester
First, share the compression package needed by LAMP on Windows (if you have any questions here, please see the previous blog article)
Second, use remote sharing on Linux to obtain files and mount them to the mnt directory
[root@localhost ~] # smbclient-L / / 192.168.100.3 / # # remote share access Enter SAMBA\ root's password: Sharename Type Comment-LAMP-C7 Disk [root@localhost ~] # mount.cifs / / 192.168.100.3/LAMP-C7 / mnt # # Mount to / mnt directory
Third, compile and install Nginx
1. Decompress the source code package to / opt, and check
[root@localhost ~] # cd / mnt # # switch to the mount point directory [root@localhost mnt] # lsapr-1.6.2.tar.gz Discuz_X2.5_SC_UTF8.zip LAMP-php5.6.txtapr-util-1.6.0.tar.gz error.png mysql-5.6.26.tar.gzawstats-7.6.tar.gz httpd-2.4.29.tar.bz2 nginx-1.12.0.tar.gzcronolog-1. 6.2-14.el7.x86_64.rpm kali.jpg php-5.6.11.tar.bz2 [root@localhost mnt] # tar zxvf nginx-1.12.0.tar.gz-C / opt # # decompress the Nginx source code package to / opt [root@localhost mnt] # cd / opt/ # # switch to [root@localhost opt] # lsnginx-1.12.0 rh under the decompressed directory
2. Install the environment package required for compilation
[root@localhost opt] # yum-y install\ gcc\ / / c language gcc-c++\ / / C++ language pcre-devel\ / / pcre language tool zlib-devel / / function library for data compression
3, create the program user nginx and compile Nginx
[root@localhost opt] # useradd-M-s / sbin/nologin nginx # # Creator user Security non-login status [root@localhost opt] # id nginxuid=1001 (nginx) gid=1001 (nginx) group = 1001 (nginx) [root@localhost opt] # cd nginx-1.12.0/ # # switch to the nginx directory [root@localhost nginx-1.12.0] # / configure\ # # configure nginx >-- prefix=/usr/local/nginx\ # installation path >-- user=nginx\ # # user name >-- group=nginx\ # # user groups >-- with-http_stub_status_module # # status statistics module
4, compile and install
[root@localhost nginx-1.12.0] # make # # compile... [root@localhost nginx-1.12.0] # make install # # install...
5. Optimize the nginx startup script to facilitate system identification
[root@localhost nginx] # ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ # # create a soft connection to let the system recognize the nginx startup script [root@localhost nginx] # nginx-t # # check the syntax problems of the configuration file nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@localhost nginx] # nginx # # Open Ngnix [root@localhost nginx] # netstat-ntap | grep 80 # # View Port Nginx has enabled tcp 0 0 0.0.0.0 LISTEN 39620/nginx: master [root@localhost nginx] # systemctl stop firewalld.service # # turn off the firewall [root@localhost nginx] # setenforce 0
6. Install the elinks web page testing tool and test it
[root@localhost nginx] # yum install elinks-y # # install elinks software [root@localhost nginx] # elinks http://localhost # # Test nginx web page
7. The service is enabled and reloaded and closed.
[root@localhost nginx] # killall-s QUIT nginx # # stop or restart using killall-3 nginx [root@localhost nginx] # killall-s HUP nginx # # or open using killall-1 nginx [root@localhost nginx] # nginx # #
8. Make management scripts that are easy to use in service management
[root@localhost nginx] # killall-s QUIT nginx # # stop or restart using killall-3 nginx [root@localhost nginx] # killall-s HUP nginx # # or open using killall-1 nginx [root@localhost nginx] # nginx # #
Access status statistics of Nginx
Enable the HTTP_STUB_STATUS status statistics module
Nginx-V can check whether the installed Nginx contains statistical modules.
First, modify the nginx configuration file
[root@localhost ~] # cd / usr/local/nginx/conf # # switch to the configuration file directory [root@localhost conf] # vim nginx.conf # # modify the Nginx configuration file server {listen 80; server_name www.kgc.com; # # indicates a domain name charset utf-8; # # Chinese character set # access_log logs/host.access.log main; location / {root html; index index.html index.htm } location / status {# # add status Statistics stub_status on; access_log off;}
Second, install DNS server for domain name resolution
1. Install the bind service
[root@localhost conf] # yum install bind-y # # install the DNS service
2, configure the main configuration file / etc/named.conf
[root@localhost conf] # vim / etc/named.conf # # main configuration file options {listen-on port 53 {any;}; # # listen locally to all 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 all
3, configure the zone profile (etc/named.rfc1912.zones)
[root@localhost conf] # vim / etc/named.rfc1912.zones # # configure the zone profile zone "localhost" IN {# # copy the template to the following type master; file "named.localhost"; allow-update {none;};}; zone "kgc.com" IN {# # modify localhost to kgc.com type master; file "kgc.com.zone" # # create allow-update {none;};}
4, edit the zone data configuration file (kgc.com.zone)
[root@localhost conf] # cd / var/named [root@localhost named] # cp-p named.localhost kgc.com.zone # # copy template is kgc.com.zone [root@localhost named] # vim kgc.com.zone # # Edit the 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.13.128 # # Delete ipv6 and add domain name resolution address as native
5. Turn off the firewall and enable the service
[root@localhost named] # systemctl start named # # enable dns service [root@localhost named] # systemctl stop firewalld.service # # turn off firewall [root@localhost named] # setenforce 0 # # disable enhanced features
6. Use win10 testing machine to test
Authorization-based access control
The configuration steps are basically the same as those of Apache
Generate user password authentication file
Modify the main configuration file to the corresponding directory and add the authentication configuration item
Restart the service and access the test
First, modify the main configuration file
[root@localhost ~] # cd / usr/local/nginx/conf # # change to the configuration file directory [root@localhost conf] # vim nginx.conf # # modify the Nginx configuration file location / {auth_basic "secret"; # # verify type auth_basic_user_file / usr/local/nginx/passwd.db; # # verify file path root html; index index.html index.htm;}
Second, install the httpd-tools toolkit and set the password authentication file
[root@localhost conf] # yum install httpd-tools-y # installation kit [root@localhost conf] # htpasswd-c / usr/local/nginx/passwd.db test # # set password authentication file New password: # # enter password Re-type new password: # # confirm password Adding password for user test [root@localhost conf] # cat / usr/local/nginx/passwd.db # # View password authentication file test:$apr1 $LqqHZeX3 $24E7/HeacTVRzKA7nvSgY/ [root@localhost Conf] # service nginx stop # # disable the service [root@localhost conf] # service nginx start # # enable the service
Third, use the win10 tester to test
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.
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.