下载安装包
树莓派上yum里没有的软件只能编译安装
wget http://cn2.php.net/distributions/php-7.2.0.tar.gz
tar -zxvf php-7.2.0.tar.gz
cd php-7.2.0
安装依赖包
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
编译 && 安装
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
编译之后开始安装
make && make install
配置PHP与Nginx
cd /usr/local/php
cp etc/php-fpm.conf.default etc/php-fpm.conf
cp etc/php-fpm.d/www.conf.default etc/php-fpm.d/www.conf
修改配置文件
vim etc/php-fpm.d/www.conf
#修改
user = nginx
group = nginx
如果报错 用户不存在:ERROR: [pool www] cannot get uid for user 'nginx'
groupadd nginx
useradd -g nginx nginx
启动php-fpm:
#root 用户启动 参数为 -R
/usr/local/php/sbin/php-fpm
若报错 file not found
修改nginx配置文件
fastcgi_param
location / {
root html;
index index.html index.htm index.php;
}
location ~\.php$ {
root /home/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
检测是否成功
新建index.php
<?php
phpinfo();
?>
加入环境变量
# vim /etc/profile
末尾添加:
export PATH=$PATH:/usr/local/php/sbin:/usr/local/php/bin
# source /etc/profile 立即生效
新操作方式
# 启动
php-fpm -R
# 停止
pkill -f php-fpm -9
#查询进程
ps -ef | grep php-fpm
个人不习惯用systemctl操作PHP,有需要的话请自行google
Comments NOTHING