#软件包名称,后面可使用name引用 Name:mnginx #软件的版本号,与源码包一致 Version:1.24.0 #发布序列号 Release:1 #软件包的内容概要 Summary:AMD64 #软件分组 Group:Development/Tools #软件授权方式 License:GPL #软件的主页 URL:http://www.sunif.cn #源代码包 Source0:%{name}-%{version}.tar.gz #这个安装或编译时使用的“虚拟目录” BuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-BuildRoot #为了解决今后安装rpm包时,并不一定把软件安装到rpm中打包的目录。必须在这里定义该标识,并在编写安装脚本的时候引用,才能实现rpm包安装时重新指定位置的功能。 Prefix: %{_prefix} #_prefix指/usr,而对其他的文件,例如/etc下的配置文件,则需要用sysconfdir标识。 Prefix: %{_sysconfdir} %define _prefix /opt/mnginx-1.24.0 #软件包详述 doc %description 国密版本NGINX #软件编译之前的处理,如解压。 %prep #打开软件包,加选项对软件包进行解压处理 去我们的SOURCE目录去找到源码包并解压 %setup -q #安装软件执行语句 %build ./configure --prefix=%{_prefix} --add-module=modules/ngx_tongsuo_ntls --with-openssl=Tongsuo-master/ --with-openssl-opt="enable-ntls" --with-http_ssl_module --with-stream --with-stream_ssl_module --with-stream_sni make -j %install ##查看BUILDROOT目录是否为空,不为空时删除里面的内容 [ "RPM_BUILD_ROOT" != "/" ] && rm -rf "RPM_BUILD_ROOT" make install DESTDIR=%{buildroot} #安装完成的操作,开防火墙、添加开机自动启动等等 %post #复制证书到指定目录 sed -i 's/ 80\;/ 8888\;/' %{_prefix}/conf/nginx.conf cat << EOF > %{_prefix}/html/index.html GM SSLTEST

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

Successful

/dev/null 2>&1 rm -rf %{_prefix} 2>/dev/null %changelog 添加国密铜锁支持