多年以前记录的rpm包制作简介记录一下(制作centos8的RPM包)

分类:Linux |

0. 安装rpm制作工具包

yum install rpm-build rpmdevtools -y


1. 在 home  下建立文件 vim .rpmmacros

内容:%_topdir /root/rpmbuild

mkdir -p /root/rpmbuild/{SPECS,BUILD,SRPMS,RPMS,SOURCES}

2. 建立目录  rpm

3. copy xxx.1.0.tar.gz 文件到  SOURCES 目录下

4. 设置specs文件, vim xxx.spec 


echo "%_topdir /home/rpmbuild" >> ~/.rpmmacros
mkdir -p /home/rpmbuild/{SPECS,BUILD,SRPMS,RPMS,SOURCES}
rpmbuild -ba 'spec文件路径'


如果出现类似错误: error: Empty %files file /srv/rpmbuild/BUILD/nginx-1.20.1/debugsourcefiles.list 

解决方法: 

rpmbuild -E "%define _topdir XXXX" --nodebuginfo -ba


如出现此警告: 应该是你的配置文件有可执行权限 , 请chmod -x 对应的配置文件, 去除执行权限即可

*** WARNING: ./etc/nginx1.20/scgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/uwsgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/path_info.conf is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/site/example.conf.ssl is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/site/example.conf is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/fastcgi.conf.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/mime.types is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/scgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/fastcgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/nginx.conf is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/koi-win is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/mime.types.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/uwsgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/fastcgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/nginx.conf.default is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/fastcgi.conf is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/win-utf is executable but has no shebang, removing executable bit
*** WARNING: ./etc/nginx1.20/koi-utf is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/service/nginx.service is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/service/nginx.service.new is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/scgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/uwsgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/path_info.conf is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/site/example.conf.ssl is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/site/example.conf is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/fastcgi.conf.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/mime.types is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/scgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/fastcgi_params.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/nginx.conf is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/koi-win is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/mime.types.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/uwsgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/fastcgi_params is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/nginx.conf.default is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/fastcgi.conf is executable but has no shebang, removing executable bit
*** WARNING: ./opt/nginx1.20/conf/win-utf is executable but has no shebang, removing executable bit



事例:

Name: xxx
Version:1.0
Release:1
Summary:this is my first rpm
Group:  RHCE
License:GPL
URL:    http://www.updateweb.cn
Source0:xxx-1.0.tar.gz
BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
#BuildRequires:
#Requires:
%description
%prep
%setup -q
%build
#configure
#make %{?_smp_mflags}
%install
rm -rf %{buildroot}
#make install DESTDIR=%{buildroot}
mkdir -p %{buildroot}/bin
cp xxx.sh %{buildroot}/bin
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/bin/xxx.sh
#doc
%changelog


以下是Centos8 下的安装记录: 

编译安装nginx  php 应用服务

yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libzip
yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++ glibc
yum -y install pcre-devel
yum install -y cmake
yum install -y cmake3
yum install -y zlib-devel
yum -y install pcre-devel
yum -y install openssl openssl-devel
安装 nginx 
./configure  --with-http_gzip_static_module --with-http_ssl_module --with-http_stub_status_module --group=www --user=www --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --with-file-aio --with-http_realip_module
安装 tengine
./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/srv/logs/nginx/error.log --http-log-path=/srv/logs/nginx/access.log --pid-path=/srv/logs/nginx/nginx.pid --sbin-path=/usr/local/bin --user=www --group=www --with-http_gzip_static_module --with-http_stub_status_module --with-http_concat_module
./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/srv/logs/nginx/error.log --http-log-path=/srv/logs/nginx/access.log --pid-path=/srv/logs/nginx/nginx.pid --user=www --group=www --with-http_gzip_static_module --with-http_stub_status_module --with-http_concat_module
php 安装mysqli 版本
./configure --prefix=/opt/php/ --with-config-file-path=/etc/php/ --with-libdir=lib64 --with-gd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-curl --with-mcrypt --with-openssl --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite=shared --enable-xml --enable-pcntl --enable-mbregex --enable-mbstring --enable-bcmath --enable-gd-native-ttf --enable-inline-optimization --enable-zip --enable-ftp --enable-sockets --enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm --disable-rpath --disable-debug


编译PHP7.4

提示unrecognized options: –with-mcrypt, –enable-gd-native-ttf
表示php7.3不支持这两个选项,
编译准备工作:
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel libzip
yum -y install gcc automake autoconf libtool make
yum -y install gcc gcc-c++ glibc
yum -y install pcre-devel updatedb
yum install -y cmake zlib-devel sqlite-devel  gd-devel libxml2-devel libcurl-devel libzip-devel

正式编译:
php7.4
./configure --prefix=/opt/php74/ --with-config-file-path=/etc/php74/ --with-libdir=lib64 --enable-gd --with-iconv --with-freetype --with-jpeg --with-curl --with-openssl --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite=shared --enable-xml --enable-pcntl --enable-mbregex --enable-mbstring --enable-bcmath --enable-inline-optimization --with-zip --enable-ftp --enable-sockets --enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm --disable-rpath --disable-debug --without-gdbm --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-maintainer-zts --enable-soap


问题记录: 

问题0:


checking for libxml-2.0 >= 2.7.6... no

configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:


Package 'libxml-2.0', required by 'virtual:world', not found 


yum install libxml2-devel


问题02:

checking for libcurl >= 7.15.5... no

configure: error: Package requirements (libcurl >= 7.15.5) were not met:


Package 'libcurl', required by 'virtual:world', not found

yum install libcurl-devel


问题1:

configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

网址: https://github.com/kkos/oniguruma 

命令:

git clone https://github.com/kkos/oniguruma

cd oniguruma

./autogen.sh

./configure --prefix=/usr --libdir=/lib64

make

sudo make install

或者: 

yum install oniguruma

问题2:

No package 'libzip' found

解决:

wget https://libzip.org/download/libzip-1.2.0.tar.gz

tar -xvf libzip-1.2.0.tar.gz

cd libzip-1.2.0

./configure

make && make install

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"

问题3:

安装mcryp扩展:

wget https://pecl.php.net/get/mcrypt-1.0.3.tgz

tar -xvf mcrypt-1.0.3.tgz

cd mcrypt-1.0.3

/opt/php74/bin/phpize

./configure --with-php-config=/opt/php74/bin/php-config

yum install -y epel-release

yum install -y libmcrypt-devel

./configure --with-php-config=/opt/php74/bin/php-config

make && make install

问题4:

安装redis扩展:

git clone https://github.com/igbinary/igbinary.git 

whereis php 

cd igbinary

/opt/php74/bin/phpize && ./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/opt/php74/bin/php-config 

make -j4 && make install 

git clone https://github.com/nicolasff/phpredis.git 

cd phpredis/ 

/opt/php74/bin/phpize && ./configure CFLAGS="-O2 -g" --enable-redis-igbinary --with-php-config=/opt/php74/bin/php-config  && make -j4 && sudo make install 

php-config 

php --ini 

vim /usr/local/php/etc/php.ini 

ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ 

ll 

yum install libtool 

配置 php.ini 

[redis]

extension = redis.so

[igbinary]

extension = igbinary.so


问题5:

php: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory


问题6: 安装swoole扩展: 

  1. git下载: https://github.com/swoole/swoole-src

  2. 使用2.0版本: git checkout 2.0

  3. 安装 : 如果你只有一个版本的php, 可以使用pecl instll swoole, 这样更快一些, 编译安装 :

    /opt/php71/bin/phpize

    ./configure --with-php-config=/opt/php71/bin/php-config

    make && make install

    image.png

  4. 配置php.ini, 添加

        [swoole]

        extension = swoole.so