系统环境说明
系统:CentOS-7-aarch64-Minimal-2009
平台:aarch64
CPU
型号:FT2000+
参考文献
Nginx
编译环境搭建
源码下载
下载nginx
源代码
下载地址 。
依赖安装
安装gcc
、openssl-devel
、sqlite-devel
、bzip2-devel
、readline-devel
sudo yum install gcc openssl-devel bzip2-devel readline-devel
编译安装Nginx
以nginx-1.19.5.tar.gz
示例编译安装nginx
。
# 在设备上解压源代码
tar xf nginx-1.19.5.tar.gz
cd nginx-1.19.5
# 配置编译环境
./configure --with-http_ssl_module --with-http_v2_module
## 编译
make -j8
## 安装
make install
创建服务启动文件
编辑/usr/lib/systemd/system/nginx.service
vim /usr/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=/usr/local/nginx/logs/nginx.pid
# Nginx will fail to start if /usr/local/nginx/logs/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 /usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置开机启动
#使用systemctl设置
sudo systemctl daemon-reload #让系统知道新的单元文件
sudo systemctl enable nginx #让系统开机启动这个服务器
sudo systemctl start nginx #启动这个服务器