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

How to build Nginx Web Services for RHEL8

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly explains "RHEL8 how to build Nginx Web service", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "RHEL8 how to build Nginx Web service" bar!

RHEL 8, please configure the yum source before building the Nginx Web service.

Environment

Red Hat Enterprise Linux release 8.0

VMware Workstation Pro 14

Building steps

[root@localhost] # systemctl stop httpd # stop httpd Prevent it from affecting Nginx [root@localhost ~] # yum install-y nginx [root@localhost ~] # systemctl start nginx [root@localhost ~] # iptables-F [root@localhost ~] # systemctl stop firewalld [root@localhost ~] # systemctl disable firewalld [root@localhost ~] # setenforce 0 [root@localhost ~] # ifconfigens33: flags=4163 mtu 1500 inet 192.168.10.118 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::e09a:769b:83f0:8efa Prefixlen 64 scopeid 0x20 ether 00:50:56:34:0d:74 txqueuelen 1000 (Ethernet) RX packets 2908 bytes 1777392 (1.6MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1800 bytes 244006 (238.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 prefixlen 128 scopeid 0x10 loop Txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0virbr0: flags=4099 mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:9c:ef:c6 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Enter 192.168.10.118 in the browser to view the status of the Nginx Web server

View the file list of the nginx package

[root@localhost ~] # rpm-ql nginx/etc/logrotate.d/nginx/etc/nginx/fastcgi.conf/etc/nginx/fastcgi.conf.default/etc/nginx/fastcgi_params/etc/nginx/fastcgi_params.default/etc/nginx/koi-utf/etc/nginx/koi-win/etc/nginx/mime.types/etc/nginx/mime.types.default/etc/nginx/nginx.conf/etc/nginx/nginx.conf.default... Omit part of the content.

Customize the home page content

[root@localhost ~] # echo "HLLO RHEL8" > / usr/share/nginx/html/index.html [root@localhost ~] # systemctl restart nginx

Enter 192.168.10.118 in the browser to view

Set up file sharing service

[root@localhost ~] # mv / usr/share/nginx/html/* / var/lib/nginx/tmp/ [root@localhost ~] # touch / usr/share/nginx/html/file {1.. 10} [root@localhost ~] # ls / usr/share/nginx/html/file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 [root@localhost ~] # systemctl restart nginx

An error of 403 Forbidden is encountered because the configuration file is not configured properly. The solution is as follows:

[root@localhost html] # grep-v "#" / etc/nginx/nginx.confuser nginx;worker_processes auto;error_log / var/log/nginx/error.log;pid / run/nginx.pid;include / usr/share/nginx/modules/*.conf;events {worker_connections 1024 } http {log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main; sendfile on; tcp_nopush on Tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include / etc/nginx/mime.types; default_type application/octet-stream; include / etc/nginx/conf.d/*.conf; server {listen 80 default_server; listen [:]: 80 default_server; server_name localhost Root / usr/share/nginx/html; include / etc/nginx/default.d/*.conf; location / {index index.html index.htm; autoindex on; autoindex_exact_size on; autoindex_localtime on; charset utf-8;}

Make changes with reference to the above configuration

[root@localhost ~] # vim / etc/nginx/nginx.conf [root@localhost ~] # systemctl restart nginx

Enter 192.168.10.118 in the browser to view the file sharing status

Set Port Mappin

View the host IP

Test the status of the file sharing service by typing 192.168.0.7Rom 118 in the browser

The Nginx Web service installed with yum on RHEL8 has better support for Chinese.

[root@localhost ~] # touch / usr/share/nginx/html/ Hello Red Hat 8.txt [root@localhost ~] # systemctl restart nginx Thank you for reading. The above is the content of "how to build Nginx Web Services in RHEL8". After the study of this article, I believe you have a deeper understanding of how to build Nginx Web services in RHEL8, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Servers

Wechat

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

12
Report