银河麒麟服务器ky10 server x86 编译安装nginx

发布时间:2023年12月18日

脚本

下载地址

https://gitcode.net/zengliguang/linux_video_audio_nginx_proxy.git

下载脚本

git  clone https://gitcode.net/zengliguang/linux_video_audio_nginx_proxy.git

代码

#关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0

# 使用yum安装git  vim lsof
yum -y install git vim  lsof  wget
# yum 安装 openssl
yum -y install openssl openssl-devel
# yum 安装 gcc环境
yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64

mkdir -p  /home/zenglg/src
cd /home/zenglg/src

git clone   https://gitclone.com/github.com/arut/nginx-rtmp-module.git

# 下载nginx服务器
# 这里我安装的是 nginx-1.25.3 版本
wget http://nginx.org/download/nginx-1.25.3.tar.gz 
tar -zxvf nginx-1.25.3.tar.gz 

cd nginx-1.25.3


mkdir /nginx/log/nginx -p
mkdir /nginx/run -p
mkdir /nginx/tmp/nginx/client -p
mkdir /nginx/tmp/nginx/proxy -p
mkdir /nginx/tmp/nginx/fcgi -p
mkdir /nginx/tmp/nginx/uwsgi -p
mkdir /nginx/tmp/nginx/scgi -p
chmod 777 -R /nginx
touch /nginx/log/nginx/error.log
touch /nginx/log/nginx/access.log
touch /nginx/run/nginx.pid
touch /nginx/run/nginx.lock
chmod 777 -R /nginx
# 

# 


#添加rtmp和openssl支持
./configure --prefix=/home/tuners/nginx \
 --error-log-path=/nginx/log/nginx/error.log \
 --http-log-path=/nginx/log/nginx/access.log \
 --pid-path=/nginx/run/nginx.pid \
 --lock-path=/nginx/run/nginx.lock \
 \
 --http-client-body-temp-path=/nginx/tmp/nginx/client \
 --http-proxy-temp-path=/nginx/tmp/nginx/proxy \
 --http-fastcgi-temp-path=/nginx/tmp/nginx/fcgi \
 --http-uwsgi-temp-path=/nginx/tmp/nginx/uwsgi \
 --http-scgi-temp-path=/nginx/tmp/nginx/scgi \
 --add-module=$(pwd)/../nginx-rtmp-module --with-http_ssl_module

make && make install
# 安装完成路径在/home/tuners/nginx/sbin/nginx
# 运行nginx
# /usr/local/nginx/sbin/nginx

cd ..
cat > nginx_start.sh << EOF
    /home/tuners/nginx/sbin/nginx -c /home/tuners/nginx/conf/nginx.conf  
EOF

cat > nginx_stop.sh << EOF
    pid=\`ps -ef|grep nginx|grep -v grep|awk '{print \$2}'\`
    kill -9 \$pid
EOF

#自启脚本
# cd /usr/lib/systemd/system/
# rm -rf nginx.service
# touch nginx.service
cat > /usr/lib/systemd/system/nginx.service << EOF
    [Unit]     
    Description=nginx    
    After=network.target          
    [Service]     
    Type=forking     
    User=root
    ExecStart=/bin/sh $(pwd)/nginx_start.sh start
    ExecStop=/bin/sh $(pwd)/nginx_stop.sh stop
    PrivateTmp=true
    TimeoutStartSec=0
    KillMode=none     
    [Install]     
    WantedBy=multi-user.target 
EOF

cd /usr/lib/systemd/system/
#设置权限
chmod -R 754 nginx.service
#设置开机自启
systemctl enable nginx.service
#启动nginx
systemctl start nginx.service
#查看nginx
systemctl status nginx.service

编译安装

切换到脚本所在路径

cd /root/linux_video_audio_nginx_proxy/

执行脚本

source centos7_nginx_online_comp_install.sh

确认服务正常启动

浏览器打开访问地址

?

文章来源:https://blog.csdn.net/zengliguang/article/details/135052671
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。