CentOS7.0安装Nginx 1.7.8

一、安装准备

 

首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++、gcc、openssl-devel、pcre-devel和zlib-devel 

 

二、安装Nginx

 

 

安装之前,最好检查一下是否已经安装有nginx

# find -name nginx

如果系统已经安装了nginx,那么就先卸载

# yum remove nginx

首先首先进入/usr/local目录

# cd /usr/local/

从官网下载最新版的nginx

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

解压nginx压缩包

# tar -zxvf nginx-1.7.8.tar.gz

会产生一个nginx-1.7.8目录,这时进入nginx-1.7.8目录

# cd nginx-1.7.8/

接下来安装,使用--prefix参数指定nginx安装的目录,make、make install安装

./configure $默认安装在/usr/local/nginx 

make

makeinstall

如果没有报错,顺利完成后,最好看一下nginx的安装目录

whereis nginx

[root@localhost ~]# whereis nginx

 

nginx: /usr/local/nginx

 

安装完毕后,进入安装后目录(/usr/local/nginx)便可以启动或停止它了。

启动:进入到目录  # cd /usr/local/nginx/sbin,执行# ./nginx

查看是否启动成功,看到以下信息,说明启动成功:

[root@localhost sbin]# ps -ef | grep nginx 

root      7106     1  0 17:42 ?        00:00:00 nginx: master process ./nginx

nobody    7107  7106  0 17:42 ?        00:00:00 nginx: worker process

root      8377  3014  0 18:03 pts/1    00:00:00 grep --color=auto nginx

#浏览器中测试 
http://ip:80

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

 

Thank you for using nginx.

注意关闭防火墙。

 

停止

#查询nginx主进程号 
ps -ef | grep nginx
#停止进程 
kill -QUIT 主进程号 
#快速停止 
kill -TERM 主进程号 
#强制停止 
pkill -9 nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值