安装PHP7.2

一、PHP安装

下载:
wget http://mirrors.sohu.com/php/php-7.2.30.tar.gz
解压:
tar -xzvf php-7.2.30.tar.gz
安装依赖:
yum install -y gcc libxml2-devel openssl openssl-devel postgresql-devel libxslt libxslt-devel
编译配置:
./configure \
--prefix=/usr/local/php7 \
--with-pdo-pgsql \
--with-zlib-dir \
--with-freetype-dir \
--enable-mbstring \
--with-libxml-dir=/usr \
--enable-soap \
--enable-calendar \
--with-curl \
--with-gd \
--with-pgsql \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-pdo-mysql \
--with-mysqli \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-openssl \
--with-fpm-user=www \
--with-fpm-group=www \
--with-libdir=/lib/x86_64-linux-gnu/ \
--enable-ftp \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-opcache \
--enable-fpm \
--with-iconv \
--with-xpm-dir=/usr
执行安装:
make && make install

二、配置成开机启动

安装php-fpm:
yum install php-fpm
复制php-fpm.conf到安装目录:
cp /etc/php-fpm.conf /usr/local/php7/etc/php-fpm.conf
复制www.conf到安装目录:
cp /etc/php-fpm.d/www.conf/usr/local/php7/etc/php-fpm.d/www.conf

创建php-fpm服务文件:内容如下(pid,php-fpm,conf路径按照自己的来适当更改,实在找不到可以用find / -name php-fpm.pid 查找)

vim /etc/systemd/system/php-fpm.service

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/run/php-fpm/php-fpm.pid
ExecStart=/usr/local/php7/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php7/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
启动PHP:
systemctl start php-fpm.service

添加到开机启动(Failed to execute operation: File exists报错可以用:systemctl disable php-fpm.service 命令清除掉:

systemctl enable php-fpm.service

三、额外指令systemctl

systemctl enable *.service #开机运行服务
systemctl disable *.service #取消开机运行
systemctl start *.service #启动服务
systemctl stop *.service #停止服务
systemctl restart *.service #重启服务
systemctl reload *.service #重新加载服务配置文件
systemctl status *.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

四、对应的php-fpm操作

systemctl stop php-fpm

systemctl start php-fpm

systemctl restart php-fpm

五:查看编译参数:

1、nginx编译参数:
your_nginx_dir/sbin/nginx -v
2、apache编译参数:
cat your_apache_dir/build/config.nice
3、php编译参数:
your_php_dir/bin/php -i |grep configure
4、mysql编译参数:
cat your_mysql_dir/bin/mysqlbug |grep configure

你可能感兴趣的:(安装PHP7.2)