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 install nginx in Centos8

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article shows you how to install nginx in Centos8. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Start installation

Install the dependency package, using the yum tool

Yum-y install gcc make zlib-devel pcre pcre-devel openssl-devel

one

First we need to add a user with the name "www" (the name is custom, www when I use it in this article)

Useradd www

one

Then set the password for www

Passwd www

one

Then we need to give the www user sudo permission, and the file of the user's sudo permission is saved in / etc/sudoers, and open the file using vim or vi

Note: root user or user with root permission is required to operate this file, so when operating this file, you need to make sure that you are a root user. You can use the whoami command to check your identity. If you are not a root user, you need to use the su command to switch to the root user.

Vim / etc/sudoers

one

What it looks like when you open this file.

Give www user rights in this location; add this sentence: www ALL= (ALL) ALL; force save and exit: wq!

Then switch to the home directory of the www user

Cd / home/www

one

Now that the preparation is done, download the nginx source package and download it using the wget tool

Wget http://nginx.org/download/nginx-1.6.3.tar.gz

one

If an error message such as the command does not exist when performing this step, it may be because the wget tool is not installed and you need to use the yum tool to install the wget tool

Yum-y install wget

one

Execute the download command after a successful installation

At this point, there will be a compressed file called nginx-1.6.3.tar.gz in www's home directory.

Switch to the www user and extract the file

Su-wwwtar-xvf nginx-1.6.3.tar.gz

one

two

After decompression, there will be a directory file called nginx-1.6.3

Let's change the owner and group of nginx-1.6.3 and its subfiles

Chown-R www:www nginx-1.6.3

one

Enter this file after the change is successful

Cd nginx-1.6.3

one

Execute configuration command

. / configure

one

Next, compile the file. After the compilation is successful, you can see a Makefile file.

Make

one

Generally, there will be problems here. Screenshots and solutions to the problems are given below.

1 、

Error reason: I don't know.

Solution: edit this file

Vim / home/www/nginx-1.6.3/src/os/unix/ngx_user.c

If you re-execute the compilation command, there will generally be no problem.

Make

one

Perform compilation and installation

Perform a compilation installation, that is, copy the compiled files to the specified directory. (copy the files in the / nginx-1.4.4 directory to / usr/local/nginx/).

Because you need to create a folder under another folder, writing the installation directly will cause an error, so you need to install it in sudo mode.

Sudo make install

one

To start the nginx server, the startup command needs to be done using sudo.

Sudo / usr/local/nginx/sbin/nginx

one

Test if the nginx server is available

Access port 80 of the server address to determine if the "welcome" page can be opened. It is found that the welcome interface cannot be accessed at this time (except for this machine) because the centos local firewall does not open port 80, which needs to be opened in the local firewall. Use the following command.

Sudo firewall-cmd-zone=public-add-port=80/tcp-permanentsudo firewall-cmd-reload

The above is how to install nginx in Centos8. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report