Recording Huawei Cloud Server (Linux Visualization Pagoda Panel) - Nginx Chapter


Configure Nginx server

1. Add the Nginx yum resource library of CentOS 7 system

  • Install firstrpm
apt install rpm

Insert image description here
prompts after execution, enter y to install successfullyrpm

  • Then execute the following command to add the Nginx yum resource library of the CentOS 7 system.
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Note:
The Nginx service version is constantly updated, which may cause the execution of this command to fail. In that case, please obtain the latest Nginx software package under the http://nginx.org/packages/centos/7/noarch/RPMS path. Replacenginx-release-centos-7-0.el7.ngx.noarch.rpmfield.
Insert image description here

The output after execution is shown below

Insert image description here

2. Install Nignx service

  • Use directly apt Installation
apt install -y nginx

Insert image description here

You can also use theyum command to install it. For details, please checkyumrelated information

  • The newly installed Nignx will not start by itself. Execute the following command to start Nignx.
sudo systemctl start nginx.service
  • Execute the following command to set auto-start at boot.
sudo systemctl enable nginx.service
  • Click the resource card in the console and obtain the public IP of the Yunyao Cloud Server L instance in the "Yanyao Cloud Server L Instance" menu.
  • Directly enter the public IP in the local browser to preview the Nginx server default page.
    If the Nginx server default page can be previewed normally, it means that the Nginx server is deployed successfully.
    Nginx server default page
    Insert image description here

3. nginx use

  • Check the open status
systemctl status nginx
or
nginx -t
or
service nginx status
  • Start nginx
systemctl start nginx
or
service nginx start
  • Close nginx
systemctl stop nginx
or
service nginx stop

windows other commands

#修改配置后重新加载生效
nginx -s reload
#重新打开日志文件
nginx -s reopen
#测试nginx配置文件是否正确
nginx -t -c /path/to/nginx.conf 


查看Nginx的版本号:`nginx -V`

启动Nginx:`start nginx`

快速停止或关闭Nginx:`nginx -s stop`

正常停止或关闭Nginx:`nginx -s quit`

配置文件修改重装载命令:`nginx -s reload`

查看windows任务管理器下Nginx的进程命令:`tasklist /fi "imagename eq nginx.exe"`

然后执行 `taskkill /f /t /im nginx.exe`退出进程

Start the operation -c parameter specifies the nginx configuration file path to be loaded

nginx -c /usr/local/nginx/conf/nginx.conf 

4. Check whether the port is being monitored normally in the instance.

netstat -an | grep 80

5. Query the nginx main process number

ps -ef | grep nginx 
#或者
ps -aux | grep nginx

6. Check whether the nginx process is started

ps  -ef|grep  nginx
从容停止Nginx:
kill -QUIT 主进程号  
例如:kill -QUIT 16391

快速停止Nginx:
kill -TERM 主进程号  

强制停止Nginx:
kill -9 主进程号 

graceful restart

If you change the configuration, you need to restart Nginx. Do you need to close Nginx first and then open it? No, you can send a signal to Nginx to restart smoothly.
Smooth restart command:

kill -HUP 住进称号或进程号文件路径  
或者使用
/usr/nginx/sbin/nginx -s reload  

Note that after modifying the configuration file, it is best to check whether the modified configuration file is correct to avoid Nginx errors after restarting, which will affect the stable operation of the server. The command to determine whether Nginx configuration is correct is as follows:

nginx -t -c /usr/nginx/conf/nginx.conf 
或者
/usr/nginx/sbin/nginx -t 

Set the Nginx security level (I feel you don’t need to set it yet)

step one

Check whether the application image starts normally, and then perform step 2 after it starts normally.
After the Yunyao Cloud Server L instance is in the "Running" state, click the resource card.
Click "Manage" in the "Image Information" area to enter the application image management page and check whether the application image starts normally.

During the startup of the application image, do not reset the password, restart or power off the Yunyao Cloud Server L instance, otherwise it may cause the application image to start abnormally.

Insert image description here
Insert image description here

  • Click on management to enter the 8888 connection. It prompts that you need to log in. You can click on the QR code in the upper right corner and click to open 堡塔APP and follow the prompts
    Insert image description here
  • If the management page displays a normal boot or login interface, it means that the application image has been started normally. Otherwise, please wait patiently for 1~2 minutes and try again later.

Step 2

The specific modification and login operations can be viewedMove to view
Since you have started by resetting the password and have already done so, you can directly log in to the settings< /span>. execute the following command to run the script
-After logging in
nginx_huaweicloud.sh

wget -N https://websoft9.github.io/stackhub/scripts/nginx_huaweicloud.sh && bash nginx_huaweicloud.sh

The Nginx security level is too high, which may cause some application functions to be unavailable. Please run the nginx_huaweicloud.sh script to set the Nginx security level.


如有启发,可点赞收藏哟~

Guess you like

Origin blog.csdn.net/weiCong_Ling/article/details/134607077