nginx既可作为网页发布,也是优秀的服务器
nginx官网:nginx.org
nginx历史版本:http://nginx.org/download/,我选择的是1.21.1版本
tar zxf nginx-1.21.1.tar.gz
解压该文件
cd nginx-1.21.1/
进入文件
./configure --help
可以查看帮助
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module
使用configure脚本安装 添加了三个模块
--without
编译时默认有该模块
--with
编译时默认没有该模块
--with-http_ssl_module
支持https
--with-http_stub_status_module
状态模块
--prefix=/usr/local/nginx
指定路径
注:nginx属于静态编译(安全),http属于动态编译(方便)
此时会报错:
安装gcc:
yum install -y gcc
执行./configure......
此时报错:
缺少pcre模块
安装pcre模块
yum install -y pcre-devel
执行./configure......
此时报错:
安装openssl模块
yum install -y openssl-devel
成功执行./configure......
结果如下图:
继续执行:
make
make读的文件即makefile
make install
把编译好的二进制程序安装到指定路径
做软连接:
ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
怎样启动nginx?
执行nginx
查看80端口
也可以使用windows浏览器访问本机ip
重启和停掉nginx