Home >Backend Development >PHP Tutorial >CentOS7 compile and install Nginx centos7.2 centos 7.0 centos 6.7

CentOS7 compile and install Nginx centos7.2 centos 7.0 centos 6.7

WBOY
WBOYOriginal
2016-07-29 08:49:071339browse

Niginx download and installation

1. Download

<code>wget http://nginx<span>.org</span>/download/nginx-<span>1.10</span><span>.0</span><span>.tar</span><span>.gz</span></code>

My software has been downloaded to /opt/soft-install
centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

2. Unzip

<code><span>#解压到当前目录</span>
tar -zxvf nginx-<span>1.10</span><span>.0</span><span>.tar</span><span>.gz</span> -C .</code>

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

3. Compile and install
First, you need to understand the meaning of the following commands
Reference: http://feinibuke.blog.51cto.com/1724260/367376

Install to the /opt/soft/nginx-1.10.0 directory

<code><span>cd</span> nginx-<span>1.10</span>.<span>0</span>/
<span># 指定安装到 /opt/soft/ngnix 的目录下</span>
./configure --prefix=/opt/soft/nginx-<span>1.10</span>.<span>0</span></code>

Tips: Lack of C compilation environment

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

Solution

<code><span>yum</span><span>install</span><span>gcc</span><span>gcc</span><span>-</span><span>c</span><span>+</span><span>+</span></code>

Continue to configure

Tips: The pcre dependency library is missing

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

Solution

<code>yum <span>install</span> pcre pcre-devel</code>

Tips: The zlib dependency library is missing

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

Solution

<code>yum <span>install</span> zlib zlib-devel</code>

As shown below, the installation environment is no longer a problem
centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

Summary: Before compiling and installing, you must ensure that the system has installed the following dependent libraries

<code>yum <span>install</span> gcc gcc-c++
yum <span>install</span> pcre pcre-devel
yum <span>install</span> zlib zlib-devel</code>

4. Installation

<code><span>make</span> & <span>make</span> install</code>

If you see the following directory structure, it means that the basic installation is OK

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

5. Test whether Nginx is installed successfully

Start Nginx

<code><span>cd</span> /opt/soft/nginx-<span>1.10</span>.<span>0</span>/
./sbin/nginx</code>

Open port 80

<code><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>z/span><span>-</span><span>-</span><span>add</span><span>-</span><span>port=80/tcp</span><span>-</span><span>-</span><span>permanent</span><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>reload</span></span></code>

Browser access 192.168.2.202
centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

The above interface appears, indicating that Nginx access is successful.

Niginx common commands

1. View Nginx process

<code>ps aux<span>|grep nginx</span></code>

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

2. View Nginx commands

<code>ngnix <span>-h</span></code>

centos,centos7 安装,centos7 下载,centos7.1,centos下载,centos中文站,centos7.2,centos 7.0,centos 6.7

3. Common Nginx commands

<code><span>#启动</span>
ngnix

<span>#停止</span>
nginx -s stop

<span>#重新加载配置</span>
nginx -s reload</code>
').addClass('pre-numbering').hide (); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces CentOS7 compilation and installation of Nginx, including centos7 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