In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the sample analysis on the compilation and installation of Nginx source code. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
The installation of the rpm package is relatively simple and is not explained here.
For most open source software, if you can not find the installation package, you can use the source code installation method. Although the source code installation is not as convenient as yum, apt and other tools, it is very general-purpose and can be used on servers of different architectures and operating systems.
Use the source code to compile and install the general way, usually to the github to search the corresponding software name, find the source code, select the appropriate version, look at the source directory under the readme.md file (in fact, this file is the source code instructions on github), if readme.md does not describe the steps to compile and install or build the project, it will also indicate where to get the corresponding documentation. There are also some software build documents written in a file called INSTALL, if the readme.md document does not have build instructions, you can try to find the INSTALL file.
For C language software, the steps for compiling the source code are usually as follows:
. / configure
Make
Make install
Usually the. / congfigure command checks the compilation environment according to the architecture and operating system of the server cpu, such as whether the required dependent components and library files are installed, or you can specify the installation location and some configuration items through parameters
The make command can specify the number of cores of cpu through the-j parameter. The more cores you use, the faster the compilation. For example, for an 8-core server, you can use make-J8 to speed up the compilation.
Make install for software installation
For nginx, the source code compilation installation steps are as follows:
Wget https://nginx.org/download/nginx-1.14.2.tar.gz
Tar-xvf nginx-1.14.2.tar.gz
Cd nginx-1.14.2
. / configure-prefix=/usr/local/nginx-with-http_ssl_module
Make-J8
Make install
/ usr/local/nginx/sbin/nginx-v
The installation directory is specified as / usr/local/nginx at. / configure, so the nginx command is in this directory after installation
If you need to deploy static pages such as html, upload static file resources to the / usr/local/nginx/html/ directory.
Edit the nginx configuration file / usr/local/nginx/conf/nginx.conf to change the user on the second line to root, or the current user. Vim text editing where enter: set nu can display the number of lines.
Uncomment line 2 and change nobody to root:
If the web application needs to support uploading files, you need to set the upper limit of uploading files and add it on line 18:
Client_max_body_size 100m;,
If you need to modify the access port of a static resource, you can modify it on line 37, for example, set it to 8081:
If you need to support request forwarding (such as accessing backend interfaces in static resources, and requests for access / api are forwarded to applications on port 18080), add the following on line 49:
Location / chat/api {proxy_pass http://127.0.0.1:18080/api; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for Proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade';}
The above configuration forwards all requests containing / chat/api/ in the access path to http://127.0.0.1:18080/api, where chat is the deployed static resource directory, and the last two lines are configured to support websocket connections, that is, ws protocol.
Through this configuration, the front and back end of web applications can be separated, that is, the front end static resources are deployed on port 8081 and the back end resources are deployed on port 18080. After deployment, you only need to start the application on nginx and port 18080 to access the web application normally.
This is the end of this article on "sample analysis of Nginx source code compilation and installation". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.