Analysis of Nginx installation examples in Linux
Use the system binary source method to install
On the ubuntu/debian system
sudo apt-get install nginx
or the redhat/centos system
sudo yum install nginx
The method is the simplest and fastest way, but it is not the best way. Let’s talk about this main problem below.
Advantages
All installation binary dependencies have been processed, no need to worry about compatibility issues, it can be used out of the box
You don’t need to deal with the connection configuration and user permissions of nginx, we have already written this for you
Don’t worry about nginx bug maintenance and upgrade issues, just get the latest system directly That’s it
Uninstallation is simple, just one command
Simple log maintenance, automatically truncate the day’s log, compress and save
Disadvantages
Cannot choose the installed version
Cannot choose the compiled module independently
Extended functions become very troublesome and need to be recompiled
The directory structure is complex, the configuration file is under /etc/, and the deployment file is under /var/www
Restarting the service and modifying the configuration require root permissions
Performance is slightly worse Compile and install
If you are a Linux newbie, it is definitely recommended to use this method of installation. You don’t need to consider compilation dependencies. You can use it directly after installation. But if your server is used in a production environment and is being developed and gradually improved, this method is not recommended. Third-party modules may be added in the future, and they must be compiled and installed at that time (discussed below). When restarting the server, do not use the root user, but use sudo to briefly gain root. If your server is used to deploy some static files, mainly for some web spaces, and usually uses the ftp tool to deploy files, there is definitely no problem with this method.
Compile and install
I won’t write about the advantages and disadvantages. Basically, just reverse the above. To install using this method, you must know a little knowledge about Linux compilation, and only moderate Linux users can control it. I saw that most tutorials on the Internet install the compilation dependencies directly in /usr/local/. This method is not good. If we want to uninstall these dependencies in the future, we will find it very troublesome. You can't just delete it directly under the category. Some Linux distributions will write the installation files into the configuration files. I don't know where to find these configuration files. If a dependent version affects other software, how to deal with version issues. We just wanted to install nginx, but it caused a lot of problems.
Compilation environment preparation
Before you start, make sure your Linux is prepared with gcc, make, wget, g software.
Create a category to store downloaded files, enter the directory to download the dependent library source files
Downloading openssl is mainly used for ssl module encryption and supports https
wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
Download pcre to implement support for address redirection, address rewriting functions, localtion instructions and regular expressions
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
Download zlib gzip compression module
wget https://zlib.net/zlib-1.2.11.tar.gz
Download nginx
wget http://nginx.org/download/nginx-1.17.1.tar.gz
Use tar to decompress all files
ls *.tar.gz | xargs -n1 tar xzvf
Compilation options
Use ./configure to set various nginx parameter scripts, including the paths to source and configuration files , compiler options, linkage handling methods and module lists. The script does this by creating the makefiles required to compile the code and install nginx open source.
参数 | 描述 |
---|---|
–prefix= | nginx安装目录,以及有其他配置脚本选项的路径设置的所有相对路径的基本位置。默认值/usr/local/nginx |
–sbin-path=nginx二进制执行文件的名称,默认值: | Copy after login 输出以下信息,说明依赖没问题 configuration summary + using pcre library: ../pcre-8.43 + using openssl library: ../openssl-1.0.2s + using zlib library: ../zlib-1.2.11 nginx path prefix: "/home/admin/nginx" nginx binary file: "/home/admin/nginx/sbin/nginx" nginx modules path: "/home/admin/nginx/modules" nginx configuration prefix: "/home/admin/nginx/conf" nginx configuration file: "/home/admin/nginx/conf/nginx.conf" nginx pid file: "/home/admin/nginx/logs/nginx.pid" nginx error log file: "/home/admin/nginx/logs/error.log" nginx http access log file: "/home/admin/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" Copy after login 编译 make Copy after login 安装 make install Copy after login 设置权限 因为linux设置普通用户,不能占用1024一下的端口,直接启动nginx会出现权限不足的错误。将nginx分配给root用户,在分配特殊权限。 sudo chown root nginx sudo chmod u+s nginx Copy after login The above is the detailed content of Analysis of Nginx installation examples in Linux. For more information, please follow other related articles on the PHP Chinese website! Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
![]() Hot AI Tools![]() Undresser.AI UndressAI-powered app for creating realistic nude photos ![]() AI Clothes RemoverOnline AI tool for removing clothes from photos. ![]() Undress AI ToolUndress images for free ![]() Clothoff.ioAI clothes remover ![]() Video Face SwapSwap faces in any video effortlessly with our completely free AI face swap tool! ![]() Hot Article
What's New in Windows 11 KB5054979 & How to Fix Update Issues
3 weeks ago
By DDD
How to fix KB5055523 fails to install in Windows 11?
2 weeks ago
By DDD
InZoi: How To Apply To School And University
3 weeks ago
By DDD
How to fix KB5055518 fails to install in Windows 10?
2 weeks ago
By DDD
Roblox: Dead Rails – How To Summon And Defeat Nikola Tesla
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
![]() Hot Tools![]() Notepad++7.3.1Easy-to-use and free code editor ![]() SublimeText3 Chinese versionChinese version, very easy to use ![]() Zend Studio 13.0.1Powerful PHP integrated development environment ![]() Dreamweaver CS6Visual web development tools ![]() SublimeText3 Mac versionGod-level code editing software (SublimeText3) ![]() Hot Topics![]() The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions. ![]() Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result. ![]() vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history. ![]() To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address. ![]() Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast. ![]() The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools. ![]() Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables) ![]() Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version ![]() |