1.安装准备
Find -name nginx 安装之前,最好检查一下是否已经安装有nginx
yum remove nginx 如果系统已经安装了nginx,那么就先卸载
2.安装依赖g++、gcc、openssl-devel、pcre-devel和zlib-deve
yum -y install gcc gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
3. 下载nginx安装包
wget http://nginx.org/download/nginx-1.12.2.tar.gz
4.解压安装包
tar -zxvf nginx-1.12.2.tar.gz
5.找到位置,进入nginx-1.6.2目录然后在执行./configure命令
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
6. 编译安装
make && make install
7.启动并查看Nginx 是否成功启动,看到如下信息说明启动成功
# /usr/local/nginx/sbin/nginx
# ps -ef | grep nginx root 24956 1 0 19:41 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 24957 24956 0 19:41 ? 00:00:00 nginx: worker process root 24959 10533 0 19:41 pts/0 00:00:00 grep --color=auto nginx[root@MiWiFi-R3-srv nginx-1.6.2]#
8.测试nginx
通过浏览器访问,直接ip加80或者不加,看到nginx首页说明成功!
nginx 命令
启动:
/usr/local/nginx/sbin/nginx
关闭:
pkill -9 nginx
/usr/local/nginx/sbin/nginx -s stop 关闭nginx
查看状态:
netstat -tulnp | grep ':80 '
ps -ef | grep nginx
修改配置文件
vi /usr/local/nginx/conf/nginx.conf