下载安装文件
[root@lizhencheng ~]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
安装Nginx
1. 安装第三方库
[root@lizhencheng ~]# yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
[root@lizhencheng ~]# yum -y install pcre-devel
2. 解压nginx-1.14.0.tar.gz到/opt/目录下
[root@lizhencheng ~]# tar -zxvf nginx-1.14.0.tar.gz -C /opt/
3. 进入/opt/nginx-1.14.0然后再执行./configure命令
[root@lizhencheng ~]# cd /opt/nginx-1.14.0
[root@lizhencheng nginx-1.14.0]# ./configure --prefix=/opt/nginx
4. 编译安装
[root@lizhencheng nginx-1.14.0]# make && make install
常用命令
测试nginx测试文件是否正确
[root@lizhencheng nginx]# sbin/nginx -t
启动nginx:
[root@lizhencheng nginx]# sbin/nginx
停止 Nginx
[root@lizhencheng nginx]# sbin/nginx -s stop
重启 Nginx
[root@lizhencheng nginx]# sbin/nginx -s reopen
nginx默认端口为80,启动成功后访问IP地址即可看到 Welcome to nginx!