In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to make PHP RPM package in linux, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
Install rpm-build
[root@linuxprobe SOURCES] # yum-y install rpm-build
Set up a workshop catalogue
[root@linuxprobe SOURCES] # vim ~ / .rpmmacros%_topdir / root/rpmbuild [root@linuxprobe SOURCES] # mkdir-pv ~ / rpmbuild/ {BUILD,RPMS,SOURCES,SPECS,SRPMS}
Under redhat, the default production path of the rpm package is under / usr/src/redhat, but CentOS does not have this directory, so we have to customize the working directory, which contains 6 directories (all uppercase is required):
BUILD: where to put the source code after decompression RPMS: rpm package storage directory after production is completed, specify a subdirectory for a specific platform (x86 / 64) SOURCES: collect source files, source materials, patch files, etc. Storage location SPECS: store spec files as the lead file for making rpm packages, with the rpm name .specSRPMS: src format rpm package location, since it is a src format package, there is no concept of platform BuiltRoot: false root Use install to temporarily install to this directory and use this directory as the root, so the directory files in this directory are the real directory files. When the packaging is complete, in the cleaning phase This directory will be deleted [root@linuxprobe SOURCES] # rpmbuild--showrc | grep topdir # workshop directory: _ topdir / root/rpmbuild-14: _ builddir% {_ topdir} / BUILD-14: _ buildrootdir% {_ topdir} / BUILDROOT-14: _ rpmdir% {_ topdir} / RPMS-14: _ sourcedir% {_ topdir} / SOURCES-14: _ specdir% {_ topdir} / SPECS-14: _ srcrpmdir% {_ topdir} / SRPMS-14: _ topdir / root/rpmbuild
Rpmbuild-showrc displays all macros, beginning with an underscore: define the use of the environment, two underscores: usually define commands, why define macros, because different systems, commands may be stored in different locations, so through the definition of macros to find the real location of commands
Collect source files script files
[root@linuxprobe SOURCES] # pwd/root/rpmbuild/SOURCES [root@linuxprobe SOURCES] # lsphp-5.4.45.tar.gz
Write SPEC files
[root@linuxprobe SPEC] # pwd / root/rpmbuild/SOURCES [root@linuxprobe SPEC] # vim php.spec% define _ user www%define _ group www%define _ prefix / usr/local/phpName: php # package name Version: 5.4.45 # version number (cannot be used) Release: 1% {? dist} # release number, corresponding to the following changelog For example, a brief description of php-5.4.45-1.el6.x86_64.rpmSummary: PHP is a server-side scripting language for creating dynamic Web pages # is recommended, which is no more than 50 characters, as detailed Use the following% descriptionGroup: Development/Languages # to fully use one of these groups: less / usr/share/doc/rpm-version/GROUPSLicense: GPLv2 # Software Licensing URL: http://www.php.net # Source related website Packager: yeho # Packer's information Vendor: OneinStack # publisher or packaging organization's information Source0:% {name} -% {version} .tar.gz # source code package, you can bring multiple sources such as Source1, Source2, etc. Later, you can also use% {source1},% {source2} to refer to the "virtual directory" Requires: libmcryptRequires: mhashRequires: mcryptRequires: libiconv # used in the installation or compilation of BuildRoot:% _ topdir/BUILDROOT # to define the php dependent package, which requires yum installation (use epel source here)% description # package details how to handle PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.%prep # software before compilation If you unzip% setup-Q # the role of the macro in silent mode and cd%build # starts compiling the software% configure-- prefix=% {_ prefix}-- with-config-file-path=% {_ prefix} / etc\-- with-fpm-user=% {_ user}-- with-fpm-group=% {_ group}-- enable-fpm-- enable-fileinfo\-- with-mysql=mysqlnd-- with-mysqli=mysqlnd-- with-pdo-mysql=mysqlnd\-- with- Iconv-dir=/usr/local-- with-freetype-dir-- with-jpeg-dir-- with-png-dir-- with-zlib\-- with-libxml-dir=/usr-- enable-xml-- disable-rpath-- enable-bcmath-- enable-shmop-- enable-exif\-- enable-sysvsem-- enable-inline-optimization-- with-curl-- enable-mbregex-- enable-inline-optimization\-- enable-mbstring-with-mcrypt-- with-gd-- enable-gd- Native-ttf-- with-openssl\-- with-mhash-- enable-pcntl-- enable-sockets-- with-xmlrpc-- enable-ftp-- enable-calendar\-- with-gettext-- enable-zip-- enable-soap-- disable-ipv6-- disable-debugmake ZEND_EXTRA_LIBS='-liconv'% {? _ smp_mflags} #% {? _ smp_mflags} means that if make compiles% install # in parallel for multiprocessors, start installing the software. For example, make installrm-rf% {buildroot} make INSTALL_ROOT=% {buildroot} installrm-rf% {buildroot} / {.sink, .depdb, .depdblock, .filemap, .lock .registry}% {_ install}-p-D-m 0755 sapi/fpm/init.d.php-fpm% {buildroot} / etc/init.d/php-fpm% {_ install}-p-D-m 0644 php.ini-production% {buildroot} /% {_ prefix} / script executed before etc/php.ini#rpm installation% preecho'/ usr/local/lib' > / etc/ld.so.conf.d/local.conf/sbin/ldconfigif [$1 = = 1 -a-z "`grep ^% {_ user} / etc/ passwd`"] Then # $1 has three values, representing action and installation type. Processing type groupadd% {_ group}-g 10000 # 1: install useradd-u 10000-g 10000-m% {_ user} # 2: upgrade fi # 0: script postif executed after uninstalling # rpm installation [$1 = = 1] Then [- z "`export PATH=' / etc/ profile`] & & echo" export PATH=% {_ prefix} / bin:\ $PATH "> > / etc/profile [- n" `grep ^ 'export PATH=' / etc/ profile` "- a-z" `grep'% {_ prefix}'/ etc/ profile` "] & sed-I" s@ ^ export PATH=\ (. *\) @ export PATH=% {_ prefix} / bin:\ 1@ "/ etc/ Profile / sbin/chkconfig-- add php-fpm / sbin/chkconfig php-fpm on Mem= `free-m | awk'/ Mem:/ {print $2}'`# the following is mainly the parameter optimization if [$Mem-le 640] Then Mem_level=512M Memory_limit=64 elif [$Mem-gt 640-a $Mem-le 1280]; then Mem_level=1G Memory_limit=128 elif [$Mem-gt 1280-a $Mem-le 2500]; then Mem_level=2G Memory_limit=192 elif [$Mem-gt 2500-a $Mem-le 3500]; then Mem_level=3G Memory_limit=256 elif [$Mem-gt 3500-a $Mem-le 4500] Then Mem_level=4G Memory_limit=320 elif [$Mem-gt 4500-a $Mem-le 8000]; then Mem_level=6G Memory_limit=384 elif [$Mem-gt 8000] Then Mem_level=8G Memory_limit=448 fi sed-I "s @ ^ memory _ limit.*@memory_limit = ${Memory_limit} M @"% {_ prefix} / etc/php.ini sed-I's @ ^ output _ buffering = @ output_buffering = On\ noutput_buffering = @'% {_ prefix} / etc/php.ini sed-I's @ ^ Cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@'% {_ prefix} / etc/php.ini sed-I's @ ^ short _ open_tag = Off@short_open_tag = On@'% {_ prefix} / etc/php.ini sed-I's @ ^ expose _ php = On@expose_php = Off@'% {_ prefix} / etc/php.ini sed-I's @ ^ request _ order.*@request_order = "CGP" @'% { _ prefix} / etc/php.ini sed-I's @ ^ Date.timezone.*@date.timezone = Asia/Shanghai@'% {_ prefix} / etc/php.ini sed-I's @ ^ post _ max_size.*@post_max_size = 50m posts'% {_ prefix} / etc/php.ini sed-I's @ ^ post _ max_filesize.*@upload_max_filesize = 50m posts'% {_ prefix} / etc/php.ini sed-I's @ ^ Upload_tmp_dir.*@upload_tmp_dir = / tmp@'% {_ prefix} / etc/php.ini sed-I's @ ^ max _ execution_time.*@max_execution_time = 5% {_ prefix} / etc/php.ini sed-I's @ ^ disable _ functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru Stream_socket_server,fsocket Popen@'% {_ prefix} / etc/php.ini sed-I's @ ^ session. Cookie _ httponly.*@session.cookie_httponly = 1 session'% {_ prefix} / etc/php.ini sed-I's @ ^ mysqlnd.cookie _ memory_statistics.*@mysqlnd.collect_memory_statistics = On@'% {_ prefix} / etc/php.ini cat >% {_ prefix} / etc/php-fpm.conf & 1 / sbin/chkconfig-- del php-fpm If [- e'/ etc/profile.d/custom_profile_new.sh'] Then sed-I's script% {_ prefix} / bin:@@' / etc/profile.d/custom_profile_new.sh else sed-I's script% {_ prefix} / bin:@@' / etc/profile fifi#%postun rpm the main function of the script% clean # clean after uninstalling is to delete BUILDrm-rf% {buildroot}% files # to specify which files need to be packaged For example, / usr/local/php%defattr (-, root,root,-)% {_ prefix}% attr / etc/init.d/php-fpm%changelog # log change segment, which mainly describes the software development record * Sat Oct 24 2015 yeho 5.4.45-1-Initial version
Php-redis.spec instance
[root@linuxprobe SOURCES] # pwd/root/rpmbuild/SOURCES [root@linuxprobe SOURCES] # lsredis-2.2.7.tgz [root@linuxprobe SOURCES] # cd.. / SPEC [root@linuxprobe SPEC] # vim php-redis.spec%global php_extdir% (/ usr/local/php/bin/php-config-- extension-dir 2 > / dev/null | | echo "undefined") Name: php-redisVersion: 2.2.7Release: 1% {? dist} Summary: The phpredis extension provides an API for communicating with the Redis key-value store.Group: Development/LanguagesLicense: PHPURL: http://pecl.php.net/package/redisSource0: redis-% {version} .tgzBuildRoot:% _ topdir/BUILDROOTRequires: phpBuildRequires: php > = 5.4.40%descriptionThe phpredis extension provides an API for communicating with the Redis key-value store.%prep%setup-Q-n redis-% {version}% build/usr/local/php/bin/phpize%configuremake% {? _ smp_mflags}% installrm-rf% {buildroot} mkdir-p% {buildroot % {php_extdir} make install INSTALL_ROOT=% {buildroot} find% {buildroot}-name redis.so-exec / bin/mv {}% {buildroot}% {php_extdir}\ # script% postif executed after rpm installation [$1 = = 1] Then [- z "``grep'^ extension_dir' / usr/local/php/etc/ php.ini`] & & echo" extension_dir =\ "% {php_extdir}\"> > / usr/local/php/etc/php.ini sed-I's @ ^ extension _ dir\ (. *\) @ extension_dir\ 1\ nextension =" redis.so "@'/ script executed before usr/local/php/etc/php.inifi#rpm uninstall% preunif [$1 = = 0] Then / etc/init.d/php-fpm stop > / dev/null 2 > & 1 sed-I'/ redis.so/d' / usr/local/php/etc/php.inifi#%postun rpm script executed after uninstallation [$1 = = 0] Then / etc/init.d/php-fpm start > / dev/null 2 > & 1fi%cleanrm-rf% {buildroot}% files%defattr (-, root,root,-)% {php_extdir} / redis.so%changelog* Sat Oct 24 2015 yeho 2.2.7-1-Initial version
Compile the rpm package
[root@linuxprobe SPEC] # rpmbuild-bb php.spec make php's rpm binary package [root@linuxprobe SPEC] # rpmbuild-bb php-redis.spec make php-redis 's rpm binary package these are all the contents of the article "how to make PHP's RPM package in linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.