In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to improve DevOps skills through Nginx commands. I hope you will get something after reading this article. Let's discuss it together.
Nginx is one of the most popular web servers among Linux and BSD users because of its rich functional instruction set and superior flexibility. If you are a Web developer, you may be using a Nginx or Apache server. Therefore, it is important to have a deep understanding of how Nginx works from the command line. Fortunately, you can improve your DevOps skills by mastering some Nginx commands. Our editors select these frequently used commands for you and provide a comprehensive discussion for launching the Linux administrator.
Nginx commands for Linux administrators
Unlike many Web servers, Nginx uses only configuration files to handle server configurations. As a result, you can take advantage of very few command-line arguments. This is useful because administrators can quickly find the commands they are looking for. Here are some widely used Nginx commands that you can use now.
9. Display Nginx version information
Some of the newer features of Nginx are only available in the latest version. As a result, administrators may encounter some compatibility issues on older servers. You can easily determine your Nginx version to see if your problem is related to the server version.
[linuxidc@localhost ~ / www.linuxidc.com] $nginx-v nginx version: nginx/1.14.1
Nginx version: nginx/1.14.1 the following command can be used to display additional information about the Nginx installation, such as configuration variables and compiler versions.
[linuxidc@localhost ~ / www.linuxidc.com] $sudo service nginx-V service ver. 1.1 sudo systemctl-V nginx
In addition, if you are running a Linux server based on Ubuntu or Debian, you can use the following command to find your version of Nginx.
Sudo apt-cache policy nginx
10. Display the help page
The Nginx help page is a good reference point for both beginners and experienced Linux administrators. You can view this reference from the Linux terminal emulator using one of the following Nginx commands.
Sudo service nginx-h # System V Init uses [linuxidc@localhost ~ / www.linuxidc.com] $systemctl-h nginx # for systemd-based distributions
Reference help pages are always a good choice because they give you a quick idea of the options available to users.
11. Use alternative configuration
The Nginx Web server provides an endless list of customized features. Administrators can easily adjust the Nginx profile to add additional functionality to their servers. The default Nginx configuration file on most systems is / etc/nginx/nginx.conf. However, it is usually best to implement customization on other configuration files first.
Sudo nginx-c ~ / linuxidc.conf
Note that we assume that your new configuration file is named test.conf. Replace this section with the actual name of your profile. You can now test the new configuration using the following command.
Sudo nginx-t-c ~ / linuxidc.conf
You can also instruct Nginx to look for the default configuration in other directories when compiling from source code. You only need to pass this directory when you configure the installation.
. / configure-- conf-path=/etc/some/other/nginx.conf
twelve。 Suppress the display of non-error messages
When testing a new configuration, you usually receive an error message. However, when you examine customizations, you will also get a lot of irrelevant information. Fortunately, the Nginx daemon provides a simple option to suppress these non-error messages, as shown below.
Sudo nginx-Q-t-c ~ / linuxidc.conf
This command tests a custom configuration file named linuxidc.conf and ignores unnecessary information in the output. This is useful for remote server administration tasks.
13. Change global directive
The global directive contains all the configuration parameters available to the Nginx server. This is one of the most sensitive parts of your Web server and requires careful attention. This-g option allows administrators to define personalized instructions for their own Web server Nginx.
Sudo nginx-g "pid / var/run/test.pid; worker_processes 2;"
This command specifies the global Nginx directive for PID and defines the number of worker processes, in this case 2. We can now test this using the alternate configuration file we used previously.
Sudo nginx-t-c ~ / test.conf-g "pid / var/run/test.pid; worker_processes 2;"
14. Change the Nginx prefix path
The prefix path contains all the files used by the Nginx Web server. It is also the directory used to configure the relative path (except the library source). By default, Nginx uses the / usr/local/nginx directory as the prefix. The following command demonstrates how to override it from the command line.
Sudo nginx-p / path/to/new/prefix
The-p flag allows us to pass through the position of the new prefix. It usually comes in handy when testing a new server. However, this option does not apply to Nginx servers with versions earlier than 0.7.53.
15. Check the stub_status module
The stub_status module exposes some very important metrics about Nginx. Administrators often use it to monitor their Linux mail servers or proxy servers. Although all pre-built Nginx binaries are provided with this module, if you compile Nginx from source code, your Nginx server may not have this binary. You can use the following command to test whether it is installed.
Sudo nginx-V 2 > & 1 | grep-color-with-http_stub_status_module
If you find that this module is missing, you can always rebuild Nginx from the source code. As shown below, you only need to include the-with-http_stub_status_module parameter when configuring Nginx.
. / configure-- with-http_stub_status_module
16. Check the Nginx path
There are several Nginx commands that can be used to check the Nginx installation path. Just like daily Linux terminal commands, you can always use the which / whereis command to check the Nginx path.
[linuxidc@localhost ~ / www.linuxidc.com] $which nginx / usr/sbin/nginx [linuxidc@localhost ~ / www.linuxidc.com] $whereis nginx nginx: / usr/sbin/nginx / usr/lib64/nginx / etc/nginx / usr/share/nginx / usr/share/man/man3/nginx.3pm.gz / usr/share/man/man8/nginx.8.gz
The above command displays all system locations that contain files related to Nginx settings. You can do this in another way by using the ps command and grepping the required information.
[linuxidc@localhost ~ / www.linuxidc.com] $ps aux | grep nginx
The location of the Nginx daemon should now be clearly visible. This is useful for developers who do not have the underlying privileges of the server machine.
After reading this article, I believe you have some understanding of "how to improve DevOps skills through Nginx commands". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
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.