前言
介绍如何通过yum或者apt-get安装php和php-fpm
适合php7.2
centos
yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install gcc-c++ geoip-devel -y
yum install php72w-cli php72w-devel mod_php72w php72w-fpm php72w-opcache php72w-gd php72w-bcmath php72w-xml -y
# php72w-lzo php72w-yaf 没有直接的包
mkdir /export/logs/php -p
cd /etc/php-fpm.d/ && mv www.conf www.conf.bak
webName=www
cat > www.conf << EOF
[${webName}]
user = webapps
group = webapps
listen = 0.0.0.0:9000
pm = static
pm.max_children = 20
pm.max_requests = 1024
pm.status_path = /php-fpm_status
request_slowlog_timeout = 2s
slowlog = /export/logs/php/php-slow.log
php_admin_value[error_log] = /export/logs/php/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
EOF
# 安装源中没有的模块, 假设模块是redis
cd /usr/local/src
phpModule=yaf
wget https://pecl.php.net/get/${phpModule} && mkdir ${phpModule}-src && tar xf ${phpModule} --strip-components 1 -C ${phpModule}-src
cd ${phpModule}-src && phpize && ./configure && make && make install
cat > /etc/php.d/${phpModule}.ini << EOF
; Enable zip extension module
extension=${phpModule}.so
EOF
ubuntu
add-apt-repository ppa:ondrej/php
apt-get install php7.2 php7.2-dev php7.2-fpm php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2-xml php7.2-intl php7.2-yac php7.2-yaf php7.2-redis php7.2-lzo php7.2-geoip php7.2-pecl php7.2-pear php7.2-dev php7.2-gd php7.2-zip php7.2-xml php7.2-bcmath