Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx website service building-- basic services, setting access permissions

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Nginx

Nginx is a high-performance, lightweight web service software with high stability, low system resource consumption and high processing ability for HTTP concurrent connections.

Why is the high concurrency processing power of nginx stronger than that of apache?

In the way of handling client requests, nginx is asynchronous non-blocking, while apache is synchronous blocking.

When a program is executing, it usually creates one process, or there can be multiple processes. A process creates at least one thread, and multiple threads share the memory of a program process. The running of the program ultimately depends on the thread to complete the operation. The number of threads is related to the number of CPU cores, and a core can emit up to two threads.

The operation of a thread is mainly divided into:

One: execute the program commands to CPU.

Second, the operation of IO (read or output data) or request network data.

Blockage

That is, when a thread performs an IO operation to get the data, the IO may take some time to wait for the data to return before it can proceed to the following command. So, at this point, the wait state of the thread is called blocking. The resources of cpu are not fully utilized.

Non-blocking

The same thread can continue to execute code commands when performing IO operations without waiting for the data to return. Cpu resources have been fully utilized.

Synchronization

Synchronization means that when a thread IO requests data, you actively "care" about the return of the data.

Async

Is that the current thread does not need to actively care about whether the data is returned or not, when the data is returned, you will be notified of relevant events.

Common command

Experimental procedure

1. Obtain the source code package on Windows remotely and mount it to Linux

2. Decompress the source code package and download the installation environment package

3. Create program users and configure Nginx service-related components

4. Compile and install

5. Optimize the Nginx service startup script and establish a command soft connection

6. Use a browser to visit 192.168.235.158 to access the home page of the Nginx service

7. Make service management script

[root@localhost nginx-1.12.0] # cd / etc/init.d/// cut into the startup configuration file directory #! / bin/bash# chkconfig:-99 20 # # comment information # description: Nginx Service Control ScriptPROG= "/ usr/local/nginx/sbin/nginx" # # set the variable to the nginx command file PIDF= "/ usr/local/nginx/logs/nginx. Pid "# # set variable PID file process number is 5346case" $1 "in start) $PROG # # enable the service ; stop) kill-s QUIT $(cat $PIDF) # # disable the service;; restart) # # restart the service $0 stop $0 start Reload) # # reload service kill-s HUP $(cat $PIDF) *) # # incorrect input prompt echo "Usage: $0 {start | stop | restart | reload}" exit 1esacexit 0 [root@localhost init.d] # chmod + x nginx / / Grant nginx execution permission [root@localhost init.d] # chkconfig-- add nginx / / add nginx to service Manager [ Root@localhost init.d] # service nginx stop / / use service to control nginx service stop [root@localhost init.d] # service nginx start// use service to control access status statistics of Nginx started by nginx service

Enable the HTTP STUB STATUS status statistics module

Add-- with-http stub status module when ● configures compilation parameters

(we have installed the statistics module by the way.)

● nginx-V to see if the installed Nginx contains the HTTP STUB_ _ STATUS module

1. Modify Nginx.conf configuration file

2. Install and configure the DNS service

[root@localhost ~] # yum-y install bind// installs the bind package of the DNS service [root@localhost ~] # vim / etc/named.conf / / Edit the main configuration file options {listen-on port 53 {any;}; # # replace the listening address 127.0.0.1 with any, 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;} # # replace authorization localhost with any [root@localhost ~] # vim / etc/named.rfc1912.zones / / Edit zone configuration file zone "bdqn.com" IN {type master;## replace localhost with domain name bdqn.com file "bdqn.com.zone"; # # specify zone data configuration file bdqn.com.zone allow-update {none;};} [root@localhost ~] # cd / var/named [root@localhost named] # cp-p named.localhost bdqn.com.zone / / copy zone data configuration file template is bdqn.com.zone [root@localhost named] # vim bdqn.com.zone / / Edit 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.235.158address # delete the content of the last line and add the domain name resolution address to the local address [root@localhost named] # systemctl start named / / enable the dns service [root@localhost named] # systemctl stop firewalld.service / / turn off the firewall [root@localhost named] # setenforce 0 / / disable the enhanced security feature

3. Start a virtual machine of WIndows system to test access status statistics.

Nginx access control authorization 1. Generate user password authentication file 2. Modify the main configuration file to the corresponding directory and add authentication configuration item 3. Restart the service and access the test

1. Modify Nginx.conf configuration file

2. Install the httpd-tools toolkit and specify the user name and password

3. Use the test machine to verify the authorization effect of access control.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report