安装FPM环境
安装php7
http://php.net/manual/zh/install.unix.nginx.php
1.下载php7的tar包,解压。http://php.net/downloads.php
2.编译。编译的过程中,会报依赖包的错误,在安装依赖包的同时,记下安装包名,打包的时候作为一个-d参数加进去。下面是一个./configure的样例。
./configure --prefix=/usr/local/php7 --with-config-file-path=/etc/php7/etc --with-config-file-scan-dir=/etc/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=odin --with-fpm-group=odin --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext -enable-session --with-curl --with-jpeg-dir --with-freetype-dir --with-bz2 --with-gmp --enable-simplexml
./configure
3.make && make install
修改php7配置文件
编写安装脚本和移除脚本
#!/bin/bash group=odin user=odin php_install_dir=/usr/local/php7/ conf_dir=/etc/ php_fpm_dir=/etc/init.d/ function check_file() { file=$1 if [ -f "${file}" ];then test -f "${file}.rpmsave" && rm -rf "${file}.rpmsave" mv "${file}" "${file}.rpmsave" fi } function check_dir() { dir=$1 if [ -d "${dir}" ];then test -d "${dir}.rpmsave" && rm -rf "${dir}.rpmsave" mv "${dir}" "${dir}.rpmsave" fi } { ! id $user >/dev/null 2>&1 ;}&& useradd "${user}" -g "${group}" chown -R odin:odin /usr/local/php7 #copy php-fpm check_file "${php_fpm_dir}php-fpm" cp ${php_install_dir}etc/php-fpm ${php_fpm_dir}php-fpm chmod +x /etc/init.d/php-fpm #copy php-fpm.conf check_file "${conf_dir}php-fpm.conf" cp ${php_install_dir}etc/php-fpm.conf ${conf_dir}php-fpm.conf #copy php-fpm.d check_dir "${conf_dir}php-fpm.d" cp -r ${php_install_dir}etc/php-fpm.d ${conf_dir}php-fpm.d #copy php.ini check_file "${conf_dir}php.ini" cp ${php_install_dir}etc/php.ini ${conf_dir}php.ini #copy php.d check_dir "${conf_dir}php.d" cp -r ${php_install_dir}etc/php.d ${conf_dir}php.d test -L /usr/local/bin/php && unlink /usr/local/bin/php #copy php check_file "/usr/local/bin/php" cp ${php_install_dir}bin/php /usr/local/bin/php mkdir -p /var/lib/php chown -R odin:odin /var/lib/php mkdir -p /search/odin/devdirs/{tmp,applogs/php-fpm} chmod 777 -R /search/odin/devdirs/tmp chmod 770 /search/odin/devdirs/applogs/php-fpm chmod +t /search/odin/devdirs/tmp
install.sh
注意这个install脚本是安装之后要执行的脚本,所以只能做一些cp或者chmod之类的操作。
#!/bin/bash php_install_dir=/usr/local/php7/ conf_dir=/etc/ php-fpm_dir=/etc/init.d/ rm -rf /usr/local/php7 function check_file() { file=$1 if [ -f "${file}" ];then test -f "${file}.rpmsave" && rm -rf "${file}.rpmsave" mv "${file}" "${file}.rpmsave" fi } function check_dir() { dir=$1 if [ -d "${dir}" ];then test -d "${dir}.rpmsave" && rm -rf "${dir}.rpmsave" mv "${dir}" "${dir}.rpmsave" fi } #copy php-fpm check_file "${php-fpm_dir}php-fpm" #copy php-fpm.conf check_file "${conf_dir}php-fpm.conf" #copy php-fpm.d check_dir "${conf_dir}php-fpm.d" #copy php.ini check_file "${conf_dir}php.ini" #copy php.d check_dir "${conf_dir}php.d" test -L /usr/bin/php && unlink /usr/local/bin/php #copy php check_file "/usr/bin/php"
remove
由于都是线上的机器,remove的脚本写的比较保守。
使用fpm命令打包
fpm -f -p /search/jingliyang/myrpm/ -s dir -t rpm -n php-desktop-specialForMaXueyong-rh6.x86_64 --epoch 0 -v 7.0.13 -C /usr/local/php7/ --verbose --description ‘php-desktop-specialForMaXueyong-7.0.12.rh6.x86_64‘ --url ‘http://php.net/manual/zh/index.php‘ -m ‘php-7.0.12‘ -d ‘libxml2-devel‘ -d ‘libxml2‘ -d ‘bzip2-devel‘ -d ‘libcurl-devel‘ -d ‘libidn-devel‘ -d ‘libjpeg-devel‘ -d ‘libpng-devel‘ -d ‘freetype-devel‘ -d ‘gmp-devel‘ -d ‘libmcrypt-devel‘ -d ‘pcre-devel‘ --post-install /search/jingliyang/myrpm/php7/php7_scripts/php_install --post-uninstall /search/jingliyang/myrpm/php7/php7_scripts/php_remove /usr/local/php7
时间: 2024-12-28 01:06:59