linux(Centos)安装php7.2.0脚本

 

1:用xshell或putty或ssh登录到linux服务器,如果用root用户登录,那你所在的位置是/root

2:创建一个install_php7.2.12.sh的文件,文件内容如下:

#!/bin/sh
#下载源代码
mkdir -p /usr/local/software;cd /usr/local/software
wget http://am1.php.net/distributions/php-7.2.12.tar.gz
#解压缩
tar -zxvf php-7.2.12.tar.gz
#进入源码目录
cd php-7.2.12
./configure --prefix=/usr/local/php --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip
make
make install
cp php.ini-development /usr/local/php/lib/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
groupadd www-data
useradd -g www-data www-data
echo "1:/usr/local/php/lib/php.ini 将 cgi.fix_pathinfo=1 设置成 0"
echo "2:修改 /usr/local/php/etc/php-fpm.d/www.conf 的user和group属性设置成www-data"
echo "export PATH=$PATH:/usr/local/php/bin" >> /etc/profile
source /etc/profile
cp /usr/local/php/bin/php /usr/local/bin/

3:给脚本可执行权限

chmod +x install_php2.0.sh

4:执行脚本 /bin/sh install_php2.0.sh

5.安装完成之后,手动执行php,检测是否安装成功。

如果出现下列信息表明安装成功

[root@server3 ~]# php -v
PHP 7.2.0 (cli) (built: Dec 13 2017 00:16:33) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies

6:好啦,可以愉快的玩刷php啦,如有问题欢迎留言交流。

 

 

你可能感兴趣的:(linux,php,centos)