In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how to configure common functions after Nginx installation". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to configure common functions after Nginx installation" can help you solve the problem.
1. The main configuration file is separated from the virtual host
If there are many virtual hosts, it seems more convenient to separate them, and they can also be divided by function and business. Here are two virtual hosts.
Complete configuration file with blank lines and comments removed:
[root@nginx-01 conf] # egrep-v "# | ^ $" nginx.conf.bak worker_processes 1 is http {worker_connections 1024;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server {listen 80; server_name localhost; location / {root html; index index.html index.htm } error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root html;}
Create a virtual host configuration directory under the / app/nginx/conf directory
Mkdir extra uses the server module to create two virtual sites, www and bbs [root@nginx-01 conf] # cat-n nginx.confession [root @ nginx-01 conf] # sed-n'10 error_page 20p' nginx.conf server {listen 80; server_name localhost; location / {root html; index index.html index.htm;} error_page 500502 503504 / 50x.html Location = / 50x.html {root html;}
Www site
[root@nginx-01 conf] # cat extra/www.conf server {listen 80; server_name www.yygg.com; location / {root html/www; index index.html index.htm;} error_page 500 502 503 504 / 50x.html; location = / 50x.html {root html;}}
Bbs site
[root@nginx-01 conf] # cat extra/bbs.conf server {listen 80; server_name bbs.yygg.com; location / {root html/bbs; index index.html index.htm;} error_page 500 502 503 504 / 50x.html; location = / 50x.html {root html/bbs;}}
Master profile configuration (nginx.conf)
Worker_processes 1 includes events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65 includes include events}
Check configuration
[root@nginx-01 conf] # / app/nginx/sbin/nginx-tnginx: the configuration file / app/nginx-1.18.0//conf/nginx.conf syntax is oknginx: configuration file / app/nginx-1.18.0//conf/nginx.conf test is successful
Create a site directory
[root@nginx-01 conf] # mkdir / app/nginx/html/ {www,bbs} [root@nginx-01 conf] # echo "http://www.yygg.com" > > / app/nginx/html/www/ index.hml [root @ nginx-01 conf] # echo" http://bbs.yygg.com" > > / app/nginx/html/bbs/ index.hml [root @ nginx-01 conf] # echo "192.168.1.5 www.yygg.com bbs.yygg.com" > / index.hml
Start the service and test
[root@nginx-01 conf] # / app/nginx/sbin/ nginx [root @ nginx-01 conf] # curl www.yygg.com http://www.yygg.com[root@nginx-01 conf] # curl bbs.yygg.com http://bbs.yygg.com2. Virtual host alias settin
Take a www site as an example, set an alias
An alias is to set up one or more domain names in addition to the main domain name.
Set the alias yygg.com for www.yygg.com.
[root@nginx-01 conf] # cat extra/www.conf server {listen 80; server_name www.yygg.com yygg.com; location / {root html/www; index index.html index.htm;} error_page 500 502 503 504 / 50x.html; location = / 50x.html {root html/www }}
Restart the nginx test
[root@nginx-01 conf] # / app/nginx/sbin/nginx-s reload [root @ nginx-01 conf] # cat / etc/hosts192.168.1.5 www.yygg.com bbs.yygg.com yygg.com [root @ nginx-01 conf] # curl yygg.com http://www.yygg.com3.Nginx status status information configuration
The state information is recorded using the `state module` module.
Enter / app/nginx/sbin/nginx-V to check whether the compilation has the above modules:
Nginx version: nginx/1.18.0built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017TLS SNI support enabledconfigure arguments:-user=nginx-- group=nginx-- prefix=/app/nginx-1.18.0/-- with-http_stub_status_module-- with-http_ssl_module
Create a virtual host for status by referring to the configuration file of title 1 _ ontology _ status.conf as follows:
Server {listen 80; server_name status.yygg.com; location / {stub_status on; access_log off;}}
The main configuration file nginx.conf appends status virtual host configuration
Sed-I'11 I include extra/status.conf;' nginx.conf
Check the syntax and restart nginx
/ app/nginx/sbin/nginx-t/app/nginx/sbin/nginx-s reload
Configure hosts resolution
192.168.1.5 status.yygg.com
Visit status.yygg.com to view
[root@nginx-01 conf] # curl status.yygg.comActive connections: 1 server accepts handled requests 4 4 4 Reading: 0 Writing: 1 Waiting: 0
Display result resolution:
Active connections: 1 # # the number of connections being processed is 1
Server # # handled 4 connections in total
Accepts # # created a total of 4 handshakes
Handled requests # # 4 requests have been processed
Reading # # number of Header messages read to the client
Writing # # number of Header messages returned to the client
Waiting # # NGinx has finished processing the number of resident instructions waiting for the next request
4. Increase error log
Error_log syntax:
Error_log file level
Keyword remains the same, file is the location of the log, and level is the error log level
Usually only use three levels of warn | error | crit
Configure the error log configuration by adding worker_processes 1; in the nging.conf file
Error_loglogs/error_log
That's right, that's it!
This is the end of the content about "how to configure common functions after Nginx installation". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.