歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> centos6.5安裝php 7

centos6.5安裝php 7

日期:2017/3/6 9:46:12   编辑:學習Linux

centos6.5安裝php 7


centos6.5安裝php 7


創建用戶和組

groupadd www

useradd -g www www

usermod -s /sbin/nologin www

安裝組件

yum install -y libxml2 libxml2-devel libxml2-python curl curl-devel libjpeg libjpeg-devel libpng libpng10 libpng10-devel libpng-devel freetype-devel libmcrypt libmcrypt-devel gd gd-devel

清理緩存

yum clean all

下載最新版本php-7.0.6

解壓

tar zxvf php-7.0.6.tar.gz -C /usr/src/

cd /usr/src/php-7.0.6/

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \

--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \

--with-libxml-dir --enable-xml --enable-bcmath \

--enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl \

--enable-mbregex --enable-fpm --enable-mbstring \

--with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash \

--enable-pcntl --enable-sockets \

--with-xmlrpc --enable-zip --enable-soap --with-mysql-sock=/data/3306/mysqld.sock \

--with-curl=/usr --with-gettext --with-iconv --enable-mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

安裝

make

make install

++++++++++++++++++++++++++++++++++++++

重點講一下,PHP7 正式移除了 mysql 擴展

使用mysqlnd驅動

如果繼續使用老版本的編譯方式

--with-mysql=/usr/local/mysql --enable-embedded-mysqli --with-mysqli=/usr/local/mysql/bin/mysql_config

在make的時候會報錯

make: *** [ext/mysqli/mysqli_embedded.lo] Error 1

所以我更改為

--enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd

才可以編譯成功

+++++++++++++++++++++++++++++++++++++++++

復制配置文件以及啟動腳本

cp php.ini-production /usr/local/php/etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

cd /usr/local/php/etc/php-fpm.d

編輯配置文件

vi www.conf

修改用戶和組為www

user = www

group = www

腳本設置權限,添加到開機自啟動

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig --level 2345 php-fpm on

啟動php-fpm

/etc/init.d/php-fpm start

查看端口是否啟動

netstat -anpt | grep php-fpm

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 25727/php-fpm

http://xxxxxx/Linuxjc/1134294.html TechArticle

Copyright © Linux教程網 All Rights Reserved