这里的示例使用 ubuntu20
tengine官网
安装
下载解压
wget http://tengine.taobao.org/download/tengine-2.3.3.tar.gz
tar -zxvf tengine-2.3.3.tar.gz
cd tengine-2.3.3
安装依赖
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev
sudo apt-get install zlib1g-dev
编译安装
(这里指定了安装位置为 /web/tengine, 默认为 /usr/local/nginx)
./configure --prefix=/web/tengine
--with-http_ssl_module
--with-http_v2_module
--with-http_gzip_static_module
--with-http_realip_module
--with-http_stub_status_module
make
sudo make install
解压的目录可以删除了
配置
在启动路径里创建软链接
sudo ln -s /web/tengine/sbin/nginx /usr/bin/nginx
配置 nginx 服务项(这里从 centos 的 yum nginx 安装拷贝了一份 service 配置)
sudo vim /lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/web/tengine/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /web/tengine/logs/nginx.pid
ExecStartPre=/usr/bin/nginx -t
ExecStart=/usr/bin/nginx -c /web/tengine/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable nginx.service
sudo systemctl start nginx.service
检查配置
查看防火墙状态
sudo ufw status
开启/关闭防火墙(ubuntu20 默认是关闭)
sudo ufw enable | disable
或者允许 80 端口(如果要用别的端口,也要放行一下)
sudo ufw allow 80/tcp
防火墙禁止端口的命令是
sudo ufw deny 80/tcp
浏览器打开地址 http://<ip>
image.png这时的 nginx 配置文件位置位于 /web/tengine/conf
网友评论