本文是我在ubuntu系统下安装openresty的过程,仅供参考
1、下载
我的放到了/usr/local
cd /usr/local
wget https://openresty.org/download/openresty-1.25.3.1.tar.gz
# 安装openresty需要的库
sudo apt-get update
sudo apt-get install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential
sudo apt-get install zlib1g-dev
2、安装
cd /usr/local
#解压
tar -zxvf openresty-1.25.3.1.tar.gz
#编译和安装
cd openresty-1.25.3.1
./configure
gmake
gmake install
此时安装完成,会出现/usr/local/openresty这个目录,即主目录
/usr/local下的openresty解压目录可以删掉:rm -rf openresty-1.25.3.1
#查看版本号:
cd /usr/local/openresty/nginx/sbin
./nginx -v
目录结构如下图所示:
3、启动
cd /usr/local/openresty/nginx/sbin
./nginx
访问地址:http://ip地址
出现上图说明启动成功
4、其他重要配置
隐藏版本号:为避免暴露信息,一般会对nginx进行隐藏版本号,配置如下
http {
...
server_tokens off;
...
server {
...
}
...
}