In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Method 1:
First of all, because some modules of nginx rely on some lib libraries, you must install these lib libraries before installing nginx. These dependent libraries are mainly glossy +, gcc, openssl-devel, pcre-devel and zlib-devel, so execute the following command to install.
# yum install gcc-c++
# yum install pcre pcre-devel
# yum install zlib zlib-devel
# yum install openssl openssl--devel
Install Nginx
Check to see if nginx is installed
# find-name nginx
If the system already has nginx installed, uninstall it first
# yum remove nginx
Start installing nginx
Go to your own file location and start downloading
# wget http://nginx.org/download/nginx-1.12.0.tar.gz
# tar-zxvf nginx-1.12.0.tar.gz
# cd nginx-1.12.0
#. / configure
# make
# make install
View nginx version
# / usr/local/nginx/sbin/nginx-V
Start and restart Nginx
Start:
# / usr/local/nginx/sbin/nginx
Restart
# / usr/local/nginx/sbin/nginx-s reload
Stop it
# / usr/local/nginx/sbin/nginx-s stop
Stop the process
# query nginx main process number
# ps-ef | grep nginx
Stop the process
# kill-QUIT main process number
Quick stop
# kill-TERM main process number
Forced stop
# pkill-9 nginx
Test port
# netstat-na | grep 80
Add Firewall Port
# vi / etc/sysconfig/iptables
Take effect
# / etc/init.d/iptables restart
[expansion]
[root@bogon nginx-1.12.0] # netstat-anpt | grep nginx
Tcp 0 0 0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0 of the LISTEN 5502/nginx.
[root@bogon nginx-1.12.0] # ss-tnlp | grep 80 / / you can find that the startup user and group are nginx
LISTEN 0128 *: 80 *: * users: (("nginx", 5502), ("nginx", 5503))
4. Check the progress of nginx
[root@bogon nginx-1.12.0] # ps aux | grep nginx / / found that only one master process and one worker process have been started
Root 5502 0.0 0.1 44824 1176? Ss 22:58 0:00 nginx: master process / usr/local/nginx/sbin/nginx
Nginx 5503 0.0 0.1 45260 1760? S 22:58 0:00 nginx: worker process
Root 5544 0.0 103328 848 pts/0 S + 23:02 0:00 grep nginx
Let's take a look at the main configuration file and see what happens.
[root@bogon nginx-1.12.0] # vi / etc/nginx/nginx.conf
3 worker_processes 1; / / here, only one startup is defined in the configuration file. Let's modify it to two to see the effect.
3 worker_processes 2; / / modified
[root@bogon nginx-1.12.0] # / usr/local/nginx/sbin/nginx-s stop
[root@bogon nginx-1.12.0] # / usr/local/nginx/sbin/nginx
[root@bogon nginx-1.12.0] # ps aux | grep nginx / / after restarting the service, you can find that the worker process has become two
Root 5557 0.0 0.1 44824 1176? Ss 23:07 0:00 nginx: master process / usr/local/nginx/sbin/nginx
Nginx 5558 0.0 0.1 45260 1792? S 23:07 0:00 nginx: worker process
Nginx 5559 0.0 0.1 45260 1760? S 23:07 0:00 nginx: worker process
Root 5561 0.0 103328 848 pts/0 S + 23:07 0:00 grep nginx
2. Configure nginx
1. Configuration file composition: main configuration file nginx.conf;fastcgi configuration file fastcgi_params
2. Note: must end with a semicolon; support built-in variables (introduced by the module) and custom variables (set variable name value, using $variable name when referencing)
3. Configuration file structure:
Global configuration
Event {
. / / mainly provides the configuration of users' concurrent connections
}
Http {
. / / configure the configuration of http service, and you can define virtual host server
}
4. Explanation
Global configuration segment:
Category: configuration necessary for normal operation; configuration related to optimizing performance; configuration for debugging and locating problems.
Configuration necessary for normal operation:
User nginx nginx; / / specify the users and groups running the worker process
Pid / var/run/nginx.pid; / / specifies the pid file path of the nginx process
Worker_rlimit_nofile 1024; / / specifies the maximum number of file descriptors to be opened per worker process
Worker_rlimit_slgpending 1024; / / specifies the maximum number of signals each user can send to the worker process.
Optimize performance-related configurations:
Worker_processes 4; / / the number of worker processes opened, which is usually reduced by one of the number of physical CPU cores, which can avoid the loss caused by process switching and can also be assigned automatically by adding the auto parameter
# worker_processes auto
Worker_cpu_affinity 0001 0010 0100 1000; / bind CPU, but does not implement isolation
The worker_priority nice; range is-20 and 19. The smaller the value, the higher the priority.
[root@bogon nginx] # ps axo comm,pid,nice | grep nginx to view nice values
Nginx 5557 0
Nginx 5558 0
Nginx 5559 0
[root@bogon nginx] # lscpu / / View CPU
Configuration for debugging and locating problems:
Daemon on; / / whether to start nginx as a daemon
Whether master_process on; runs nginx in the master/worker model
Error_log / var/log/nginx/error.log; / / can be followed by a level, which can be set to debug for debugging, but must take effect at compile time using the-with-debug option
Method 2:
Automatic installation selects the fastest source
# yum install yum-fastestmirror
Install nginx
# yum install nginx
Configure the nginx source yourself
# vi / etc/yum.repos.d/nginx.repo
# nginx.repo
[nginx]
Name=nginx repo
Baseurl= http://nginx.org/packages/centos/6/$basearch/
Gpgcheck=0
Enabled=1
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.