麒麟系统编译安装Nginx及打包离线包部署

系统环境:Kylin V10桌面版

前提:网络连接正常,如无网络可使用文后离线包。

1、切换到root用户

sudo -i

 输入root用户密码,回车即可。

2、安装必要的构建工具

sudo apt update

sudo apt install build-essential libpcre3 libpcre3-dev libssl-dev zlib1g-dev

3、下载Nginx

从Nginx的官方网站或使用wget下载Nginx的最新稳定版本源码,本文以nginx-1.20.1为例。

wget http://nginx.org/download/nginx-1.20.1.tar.gz

4、解压

tar -zxvf nginx-1.20.1.tar.gz

 5、配置Nginx

#切换到解压后的nginx目录

cd nginx-1.20.1

#配置
./configure \
   --with-pcre-jit --user=root \
   --prefix=/root/nginx \
   --with-http_ssl_module \
   --with-http_v2_module 

指定用户为root用户,指定路径为/root/nginx

当出现以下内容,说明配置没有问题。

Configuration summary
  + using PCRE library: ../pcre-8.43
  + using OpenSSL library: ../openssl-1.0.2s
  + using zlib library: ../zlib-1.2.11

  nginx path prefix: "/root/nginx"
  nginx binary file: "/root/nginx/sbin/nginx"
  nginx modules path: "/root/nginx/modules"
  nginx configuration prefix: "/root/nginx/conf"
  nginx configuration file: "/root/nginx/conf/nginx.conf"
  nginx pid file: "/root/nginx/logs/nginx.pid"
  nginx error log file: "/root/nginx/logs/error.log"
  nginx http access log file: "/root/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp" 

6、编译安装

make

make install

 安装完成后,切换到root路径下即可看到一个nginx的文件夹

cd /root

进入到nginx目录中的conf目录中,可以对nginx.conf进行配置,具体配置和参数此处就不再赘述,不懂的自行百度。

7、打包离线包

tar -czvf nginx-green.tar.gz nginx

在/root目录下会生成一个nginx-green.tar.gz的文件,此文件即是离线包,拷贝该文件到其他麒麟系统中按照以下操作即可直接使用。

8、解压离线包

#切换到root用户
sudo -i

#解压
tar -zxvf /home/kylin/桌面/nginx-green.tar.gz -C /home/

解压到/home目录,加压完成后在/home目录下会多出nginx文件夹

9、启动Nginx

cd /home/nginx/sbin

./nginx -p /home/nginx -c /home/nginx/conf/nginx.conf

10、验证

打开浏览器,在地址栏中输入localhost,回车,如果看到以下界面即启动成功。

11、Nginx的其他操作

#停止Nginx
sudo ./nginx -p /home/nginx -s quit

#或
sudo ./nginx -p /home/nginx -s stop

#重新加载
sudo ./nginx -p /home/nginx -s reload

如果是在root用户下则sudo可省略。

经过以上步骤,Nginx的安装和离线包部署即完成,由于系统环境的多样性,在安装过程中可能会遇到不同的问题,具体问题具体分析。

最后:资源文件下载,Nginx源码和离线包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

平凡技术人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值