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 compile and install nginx for linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains how linux compiles and installs nginx. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to compile and install nginx with linux.

The CVM discounts for Aliyun and Baidu Cloud on Singles Day this year are still good. The editor has bought Aliyun's service for three years and Baidu Cloud for one year, and it is still very good to use it for development testing after buying it. Of course, you have to configure the environment and install a series of software, such as nodejs, mongodb, mysql, nginx and so on.

At the beginning of this article, the editor will organize the process of configuring the server into a series of articles. In this article, we first introduce how to install nginx and start a web service.

First of all, log in to the server first. If linux logs in remotely, use the ssh command, open a command line on the local computer, and enter the following command:

The ssh is followed by the user name @ server. After entering the public network ip;, you need to enter the password. The password will not be displayed. The actions are as follows:

After logging in, go to the home directory, under the home directory, create a new geek, download all our software in this directory, enter the geek directory, and download nginx.

The download page of the nginx official website is shown in the figure:

We need to install the latest stable version, stable version. We download it with the wget command and go to the geek directory:

After the download is completed, the figure is as follows:

After the download is completed, we need to compile three steps before we can install it. After the download is complete, we first need to decompress it.

The following output appears during the decompression process:

Enter the decompressed file, as shown in the figure:

The configure in this is the compiler, src is the nginx source code, and man is the program that determines the system.

Next, it cannot be compiled, because if compiling and installing nginx, the system needs to install several dependent programs.

The installation commands are as follows:

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

Openssl-devel

Six dependencies are installed with yum: gcc, zlib, zlib-devel, pcre-devel, openssl, openssl-devel.

The installation process is relatively long, and there are many outputs. The installation is completed as shown in the figure:

After that, the first step of compilation begins. The first step is to compile with the configure extracted above, so go to the unzipped directory and execute the compilation. When compiling, you need to specify the installation directory. We can use the-- help instruction to see which parameters configure can set as shown in the figure:

The red box in the figure above shows that the prefix parameter is set to the installation directory, and most of our future installation software will be installed in the / home/geek directory, so execute the following command:

The implementation results are as follows:

View the current directory:

There is an extra objs directory, which is the compiled file. Go to this directory to check the contents:

For a src file and several other files, the nginx program has not been compiled at this time, and the nginx source code is in the src directory. Go back to the directory where you just executed configure, and proceed to the second step of compilation:

The execution process is shown in the figure:

After the execution is completed, it is shown in the figure:

At this point, go to the objs directory again and view the files:

Now that the nginx program has been compiled, the last step is to install the compiler, install it to the directory set in the first step, and run the make install command:

At this point, check the geek directory, add one more nginx directory, enter the directory, and view the directory structure:

It is found that there is a file, and the executable file of nginx is in sbin

Execute nginx on the command line and a web server is started.

Then visit your public network ip in the browser and you can see the website.

At this point, I believe you have a deeper understanding of "how linux compiles and installs nginx". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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