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

Steps to install and configure nginx for Centos8 Yum

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

Share

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

Nginx is a very popular web server recently, and this time CentOS8 has also added nginx 1.14 to the official source of Yum.

Can bear more concurrency and take up less memory than Apache

CentOS8 uses a new generation of yum, using dnf as the command (the original yum exists as a soft link to dnf)

Install dnf install nginx-y

If something goes wrong, check the network and yum source, and how to change the yum source to Ali source.

Set up two virtual hosts below

Virtual hosts allow one web server to serve multiple websites, each with different settings, different languages, and independent logs

It is assumed that the two hosts are

Game.shaochenfeng.commap.shaochenfeng.com

First edit the main configuration file of nginx, if there are many virtual hosts, it should be written into multiple configuration files (how about?)

Vim / etc/nginx/nginx.conf

You can see that there is a default website inside. Ignore it, insert the configuration of two websites at the red arrow.

Server {listen 80; listen [:]: 80; access_log / usr/share/nginx/log/game.shaochenfeng.com; error_log / usr/share/nginx/log/game.shaochenfeng.com.err error; server_name game.shaochenfeng.com; root / usr/share/nginx/game.shaochenfeng.com Location / {}} server {listen 80; listen [:]: 80; access_log / usr/share/nginx/log/map.shaochenfeng.com; error_log / usr/share/nginx/log/map.shaochenfeng.com.err error; server_name map.shaochenfeng.com; root / usr/share/nginx/map.shaochenfeng.com Location / {}}

Save and exit

Create the home directory and log directory of the virtual host below

Mkdir / usr/share/nginx/game.shaochenfeng.com # create the home directory and log directory of the virtual host mkdir / usr/share/nginx/map.shaochenfeng.com# copy your website files to the corresponding directory above mkdir / usr/share/nginx/logchown nginx:nginx-R / usr/share/nginx/game.shaochenfeng.com # nginx runs under the nginx user, so grant permissions chown nginx:nginx-R / usr/share/nginx/map.shaochenfeng.com to the website files

Boot and boot boot nginx

Systemctl enable nginx # set nginx boot systemctl start nginx # launch nginxsystemctl status nginx # check nginx status

Like this,

You will get / usr/share/nginx/game.shaochenfeng.com/index.html when you visit game.shaochenfeng.com

You will get / usr/share/nginx/map.shaochenfeng.com/index.html when you visit map.shaochenfeng.com

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