Centos7安装Nginx

下载nginx-1.14.0.tar.gz 

放到/usr/local/src目录下

tar -zxvf nginx-1.14.0 

CentOS 7 下 安装 Nginx执行配置命令

./configure --prefix=/usr/local/nginx

时提示以下错误:

[root@localhost nginx-1.14.0]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 3.10.0-123.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

解决:安装gc++

执行以下命令:

yum -y install gcc gcc-c++ autoconf automake make

结果在执行yum出现error

[root@localhost nginx-1.14.0]# yum -y install gcc gcc-c++ autoconf automake make

Loaded plugins: fastestmirror, langpacks
Existing lock /var/run/yum.pid: another copy is running as pid 13211.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory : 190 M RSS (1.0 GB VSZ)
    Started: Tue Aug  7 21:20:31 2018 - 1:46:16 ago
    State  : Sleeping, pid: 13211

可以通过强制关掉yum进程:

[root@localhost nginx-1.14.0]# rm -f /var/run/yum.pid

再次configure出现

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

缺少了PCRE库 

[root@localhost nginx-1.14.0]# yum -y install pcre-devel

Transaction Summary
========================================================================================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total size: 902 k
Total download size: 480 k
Downloading packages:
pcre-devel-8.32-17.el7.x86_64.rpm                                                                                                | 480 kB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : pcre-8.32-17.el7.x86_64                                                                                                              1/3 
  Installing : pcre-devel-8.32-17.el7.x86_64                                                                                                        2/3 
  Cleanup    : pcre-8.32-12.el7.x86_64                                                                                                              3/3 
  Verifying  : pcre-devel-8.32-17.el7.x86_64                                                                                                        1/3 
  Verifying  : pcre-8.32-17.el7.x86_64                                                                                                              2/3 
  Verifying  : pcre-8.32-12.el7.x86_64                                                                                                              3/3 

Installed:
  pcre-devel.x86_64 0:8.32-17.el7                                                                                                                       

Dependency Updated:
  pcre.x86_64 0:8.32-17.el7                                                                                                                             

Complete!

再次configure

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

缺少zlib

[root@localhost nginx-1.14.0]# yum install -y zlib-devel
Transaction Summary
========================================================================================================================================================
Install  1 Package
Upgrade             ( 1 Dependent package)

Total size: 140 k
Total download size: 50 k
Downloading packages:
zlib-devel-1.2.7-17.el7.x86_64.rpm                                                                                               |  50 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : zlib-1.2.7-17.el7.x86_64                                                                                                             1/3 
  Installing : zlib-devel-1.2.7-17.el7.x86_64                                                                                                       2/3 
  Cleanup    : zlib-1.2.7-13.el7.x86_64                                                                                                             3/3 
  Verifying  : zlib-devel-1.2.7-17.el7.x86_64                                                                                                       1/3 
  Verifying  : zlib-1.2.7-17.el7.x86_64                                                                                                             2/3 
  Verifying  : zlib-1.2.7-13.el7.x86_64                                                                                                             3/3 

Installed:
  zlib-devel.x86_64 0:1.2.7-17.el7                                                                                                                      

Dependency Updated:
  zlib.x86_64 0:1.2.7-17.el7                                                                                                                            

Complete!

再次configure ok

[root@localhost nginx-1.14.0]# make && make install

查看nginx版本

[root@localhost sbin]# /usr/local/nginx/sbin/nginx -v

启动nginx

Nginx启动文件地址】 -c 【Nginx配置文件地址】

[root@localhost sbin]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@localhost sbin]# ps -ef|grep nginx
root      26540      1  0 01:20 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody    26541  26540  0 01:20 ?        00:00:00 nginx: worker process
root      26543  12467  0 01:20 pts/0    00:00:00 grep --color=auto nginx
[root@localhost sbin]# 

三种关闭方式

从容停止 : Kill -QUIT 26540
快速停止 : kill -TERM 26540或 kill -INT 26540
强制停止 : pkill -9 nginx

重启

第一种reload命令:

[root@localhost local]# cd /usr/local/nginx/sbin/
[root@localhost sbin]# ./nginx -s reload

第二种发送信号方式:

[root@localhost local]# kill -HUP 26540
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在CentOS7安装NGINX,你需要按照以下步骤进行操作: 1. 首先,你需要准备好安装NGINX的环境。这包括安装GCC编译器。使用以下命令安装GCC环境: ``` $ yum install -y gcc ``` 2. 下载NGINX安装文件。你可以从NGINX官方网站下载最新版本的NGINX压缩包。将下载好的文件解压缩: ``` $ tar -zxvf nginx-1.20.2.tar.gz ``` 3. 进入解压后的NGINX目录,执行以下命令编译和安装NGINX: ``` $ cd nginx-1.20.2 $ ./configure $ make $ make install ``` 4. 安装完成后,你可以通过以下命令启动NGINX服务: ``` $ nginx ``` 5. 在浏览器中访问服务器的IP地址或域名,你应该能够看到NGINX的欢迎页面,这表明NGINX已成功安装并正在运行。如果你想在系统启动时自动启动NGINX服务,可以执行以下命令: ``` $ systemctl enable nginx ``` 请注意,这里提供的步骤是一种常见的安装NGINX的方法,具体的步骤可能因个人系统环境而有所不同。如果你遇到任何问题,可以参考NGINX的官方文档或在相关技术社区寻求帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Linux操作系统CentOS7安装Nginx[详细版]](https://blog.csdn.net/Wei_Naijia/article/details/124228897)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Centos7安装配置nginx](https://blog.csdn.net/Siebert_Angers/article/details/126960866)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [centos7安装nginx1.16.1](https://download.csdn.net/download/readyoften/13093228)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值