1 下载:
OpenResty® - 开源官方站
2 通过xftp等方式上传到ubuntu服务器
3 安装
#解压
tar zxvf openresty-1.25.3.1.tar.gz
#创建运行用户
sudo groupadd www
sudo useradd -g www www -s /bin/false
#安装依赖软件
sudo apt update
sudo apt-get install libpcre3-dev libssl-dev perl make build-essential zlib1g-dev libgd-dev
#到文件目录
cd openresty-1.25.3.1/
#安装选项
./configure --prefix=/usr/local/openresty --user=www --group=www --with-http_gzip_static_module --with-threads --with-http_ssl_module --with-http_image_filter_module --with-debug --with-http_stub_status_module --with-http_v2_module --with-stream
#编译和安装
make
sudo make install
#安装成功如图
4 配置服务器环境变量
sudo vim /etc/profile
export PATH=/usr/local/openresty/nginx/sbin:$PATH
source /etc/profile
#查看版本
nginx -V
nginx version: openresty/1.25.3.1
built by gcc 13.2.0 (Ubuntu 13.2.0-23ubuntu4)
built with OpenSSL 3.0.13 30 Jan 2024
TLS SNI support enabled
5 配置系统启动服务
#创建服务文件
sudo vim /usr/lib/systemd/system/nginx.service
[Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/bin/rm -f $PIDFile
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -c /usr/local/openresty/nginx/conf/nginx.conf
ExecStart=/usr/local/openresty/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#重新加载服务
sudo systemctl daemon-reload
#启动
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
6 web访问
欢迎一起交流(⊙﹏⊙)