`

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

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics