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

Example Analysis of rpm installation Nginx and configuration of CentOS system

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you the CentOS system rpm installation Nginx and configuration example analysis, I hope you will learn something after reading this article, let's discuss it together!

CentOS rpm installation Nginx and configuration

Official download address: http://nginx.org/en/download.html

Introduction

Nginx ("engine x") is a high-performance Web and reverse proxy server developed by Russian programmer Igor Sysoev, as well as an IMAP/POP3/SMTP proxy server.

Rpm package installation # install nginx,rpm installation # rpm installation nginx package rpm-Uvh-- force-- nodeps nginx-1.16.1-1.el7.ngx.x86_64.rpm# View Startup status systemctl status nginx display is as follows: ● nginx.service-nginx- high performance web server Loaded: loaded (/ usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since five 2021-11-26 11:12:41 CST 5 days ago Docs: http://nginx.org/en/docs/ Process: 1379 ExecStart=/usr/sbin/nginx-c / etc/nginx/nginx.conf (code=exited Status=0/SUCCESS) Main PID: 1543 (nginx) Tasks: 5 CGroup: / system.slice/nginx.service ├─ 1543 nginx: master process / usr/sbin/nginx-c / etc/nginx/nginx.conf ├─ 1544 nginx: worker process ├─ 1546 nginx: worker process ├─ 1547 nginx: worker process └─ 1548 nginx: worker process11 26 11:12:41 liang systemd [1]: Starting nginx- High performance web server...11 26 11:12:41 liang systemd [1]: Started nginx-high performance web server.# startup systemctl start nginx# restart systemctl restart nginx# boot self-startup service systemctl enable nginx# check boot status enabled: on Disabled: turn off systemctl is-enabled nginx

Modify the / etc/nginx/conf.d/default.conf configuration file after installation. The references are as follows:

Vim / etc/nginx/conf.d/default.confserver {listen 80; server_name localhost; # charset koi8-r; # access_log / var/log/nginx/host.access.log main; location / ui {alias / data/dist; index index.html index.htm;} location / file/ {root / home/data/; index index.html index.htm } # websocket configuration wss location / liangws/ {proxy_pass http://192.168.0.19:8080/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Remote_addr $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for Proxy_read_timeout 600s;} location ~ / gat {proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:18080;} # error_page 404 / 404.html # redirect server error pages to the static page / 50x.html # error_page 500 502 503 504 / 50x.html; location = / 50x.html {root / usr/share/nginx/html;} # proxy the PHP scripts to Apache listening on 127.0.0.1 virtual 80 # # location ~. Php$ {# proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1 pass the PHP scripts to FastCGI server listening on 9000 # # location ~\. Php$ {# root html; # fastcgi_pass 127.0.0.1 php$ 9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name; # include fastcgi_params #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # # location ~ /\ .ht {# deny all; #}}

Note: static file downloads depend on nginx. We need to put these files in the directory corresponding to / home/data/aaa in the nginx configuration file.

Start the service configuration cat / usr/lib/systemd/system/ nginx.service [unit] Description=nginx-high performance web serverDocumentation= http://nginx.org/en/docs/After=network-online.target remote-fs.target nss-lookup.targetWants=network- online.target [service] Type=forkingPIDFile=/var/run/nginx.pidExecStart=/usr/sbin/nginx-c / etc/nginx/nginx.confExecReload=/bin/kill-s HUP $MAINPIDExecStop=/bin/kill-s TERM $MAINPID [install] WantedBy=multi-user.target finished reading this article I believe you have some understanding of "sample Analysis of rpm installation Nginx and configuration of CentOS system". 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.

Share To

Development

Wechat

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

12
Report