根据上述建议编写一个源码编译nginx的shell脚本
时间: 2024-01-28 20:06:48 浏览: 84
好的,以下是一个简单的编译nginx的shell脚本,你可以根据需要进行修改:
```
#!/bin/bash
set -e
# nginx version
VERSION=1.20.1
# download nginx source code
curl -LO http://nginx.org/download/nginx-$VERSION.tar.gz
# extract nginx source code
tar zxf nginx-$VERSION.tar.gz
# configure nginx with required modules and options
cd nginx-$VERSION
./configure --with-http_ssl_module --with-http_v2_module --with-threads --with-file-aio --with-cc-opt='-O2' --prefix=/usr/local/nginx
# compile and install nginx
make -j$(nproc)
make install
# cleanup
cd ..
rm -rf nginx-$VERSION
rm nginx-$VERSION.tar.gz
echo "nginx $VERSION has been successfully installed to /usr/local/nginx"
```
注意:这个脚本假设你已经安装了必要的依赖(例如gcc、make等)。如果你需要的话,可以在脚本中添加安装依赖的命令。
阅读全文