官网下载
解压
- tar -zxvf nginx-1.17.3.tar.gz
###v 下载所需要的依赖库文件 - yum install pcre
- yum install pcre-devel
- yum install zlib
- yum install zlib-devel
- yum -y install make zlib-devel gcc-c++ libtool openssl openssl-devel
进行configure配置
- cd nginx-1.17.3
- ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-pcre --with-stream查看是否报错
编译安装
- make && make install(
注意如果不添加上面的所依赖库会报错
)
启动Nginx
- 首次启动需要指定配置文件启动/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- cd /usr/local/nginx/目录下:看到如下四个目录
- conf配置文件 html网页文件 logs日志文件 sbin主要二进制程序
- 启动命令:/usr/local/nginx 关闭(-s stop) 重启 (-s reload)
成功与否
- 成功:查看是否启动(
netstat -ano|grep 80
) 失败:可能为80端口被占用等。 - 浏览器访问地址:http://192.168.231.128:80(看到欢迎界面即可)