search
HomeBackend DevelopmentPHP TutorialDetailed graphic tutorial for installing Nginx under Linux

What is Nginx?

Nginx ("engine x") is a high-performance HTTP and reverse proxy server. It is also an IMAP/POP3/SMTP proxy server. In the case of high connection concurrency, Nginx is an Apache server. A good substitute. It is characterized by less memory and strong concurrency. In fact, nginx’s concurrency capability does perform better among web servers of the same type. Currently, the users of nginx websites in mainland China include: Sina, NetEase, Tencent, and others The well-known microblog Plurk also uses nginx.

Nginx as a load balancing server:

Nginx can not only directly support Rails and PHP programs internally to provide external services, but also support external services as an HTTP proxy server. Nginx is written in C, and its system resource overhead and CPU usage efficiency are much better than Perlbal. As a mail proxy server:

Nginx is also a very good mail proxy server (one of the earliest purposes of developing this product is also as a mail proxy server), Last.fm describes the successful and wonderful use experience. Nginx is a server that is very easy to install, has a very concise configuration file (it can also support perl syntax), and has very few bugs: Nginx is particularly easy to start and can run almost 7*24 without interruption, even if it runs for several months. Restart. You can also upgrade the software version without interrupting service.

Nginx installation

Module dependencies Nginx needs to depend on the following 3 packages

1. The gzip module requires the zlib library (Download: http://www.zlib.net/ )

2. The rewrite module requires the pcre library (Download: http://www.pcre.org/)

3. The ssl function requires the openssl library (Download: http://www. openssl.org/ )

Nginx package download: http://nginx.org/en/download.html

The dependency package installation order is: openssl, zlib, pcre, and then install the Nginx package.

Illustrated tutorial

Step 1: Download and install the required packages

openssl-fips-2.0.2.tar.gz

zlib-1.2.7.tar.gz

pcre-8.21.tar.gz

nginx-1.2.6.tar.gz

Step 2: Install openssl-fips-2.0 in sequence. 2.tar.gz, zlib-1.2.7.tar.gz, pcre-8.21.tar.gz, nginx-1.2.6.tar.gz

1. Install openssl-fips-2.0.2.tar. gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf openssl-fips-<span>2.0</span>.<span>2</span>.<span>tar</span><span>.gz 

[root@localhost mrms]# cd openssl</span>-fips-<span>2.0</span>.<span>2</span><span>[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# ./<span>config 

[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# <span>make</span><span>[root@localhost openssl</span>-fips-<span>2.0</span>.<span>2</span>]# <span>make</span><span>install</span></span>

2. Install zlib-1.2.7.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf zlib-<span>1.2</span>.<span>7</span>.<span>tar</span><span>.gz

[root@localhost mrms]# cd zlib</span>-<span>1.2</span>.<span>7</span><span>[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# ./<span>configure 

[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# <span>make</span><span>[root@localhost zlib</span>-<span>1.2</span>.<span>7</span>]# <span>make</span><span>install</span></span>

3. Install pcre-8.21.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf pcre-<span>8.21</span>.<span>tar</span><span>.gz

[root@localhost mrms]# cd pcre</span>-<span>8.21</span><span>[root@localhost pcre</span>-<span>8.21</span>]# ./<span>configure 

[root@localhost pcre</span>-<span>8.21</span>]# <span>make</span><span>[root@localhost pcre</span>-<span>8.21</span>]# <span>make</span><span>install</span></span>

4. Install nginx -1.2 .6.tar.gz

<span>[root@localhost mrms]# <span>tar</span> -zxvf nginx-<span>1.2</span>.<span>6</span>.<span>tar</span><span>.gz 

[root@localhost mrms]# cd nginx</span>-<span>1.2</span>.<span>6</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# ./configure --with-pcre=../pcre-<span>8.21</span> --with-zlib=../zlib-<span>1.2</span>.<span>7</span> --with-openssl=../openssl-fips-<span>2.0</span>.<span>2</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# <span>make</span><span>[root@localhost nginx</span>-<span>1.2</span>.<span>6</span>]# <span>make</span><span>install</span></span>

Now the installation of Nginx is completed!

Step 3: Check whether the installation is successful

<span>[root@localhost nginx-<span>1.2</span>.<span>6</span>]# cd  /usr/local/nginx/<span>sbin

[root@localhost sbin]# .</span>/nginx -t</span>

The following prompt appears, indicating that the installation is successful

Start nginx

<span>[root@localhost sbin]# ./nginx</span>

View the port

<span>[root@localhost sbin]# netstat -ntlp</span>

The results are as follows

Please indicate the source when reprinting [http://www .cnblogs.com/dennisit/archive/2012/12/26/2834719.html]

The above introduces the detailed graphical tutorial for installing Nginx under Linux, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
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
Optimize PHP Code: Reducing Memory Usage & Execution TimeOptimize PHP Code: Reducing Memory Usage & Execution TimeMay 10, 2025 am 12:04 AM

TooptimizePHPcodeforreducedmemoryusageandexecutiontime,followthesesteps:1)Usereferencesinsteadofcopyinglargedatastructurestoreducememoryconsumption.2)LeveragePHP'sbuilt-infunctionslikearray_mapforfasterexecution.3)Implementcachingmechanisms,suchasAPC

PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor