(OK) centos7 编译 php-7.0.0RC5

---------------------------------------//centos7 编译 php-7.0.0RC5

[root@localhost php-7.0.0RC5]# pwd
/opt/project/php-7.0.0RC5
[root@localhost php-7.0.0RC5]#
[root@localhost php-7.0.0RC5]# ./buildconf --force

#####安装编译php7时需要的依赖包
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel

##### install all of the required packages
yum install gcc libxml2-devel pkgconfig openssl-devel bzip2-devel libpng-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel httpd-devel

#####PHP7编译参数的配置
./configure --prefix=/usr/local/php7 --with-config-file-path=/etc --enable-mbstring --enable-zip --enable-bcmath --enable-pcntl --enable-ftp --enable-exif --enable-calendar --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-curl --with-mcrypt --with-iconv --with-gmp --with-pspell --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf --enable-gd-jis-conv --with-openssl --with-pdo-mysql=/usr --with-gettext=/usr --with-zlib=/usr --with-bz2=/usr --with-recode=/usr --with-mysqli=/usr/bin/mysql_config --with-apxs2

#######新建php用户和php组
groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php

make -j4 && make install


#####PHP7编译参数的配置  这个命令不用
./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-mysql-sock=/tmp/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl --with-mysql=shared,mysqlnd --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --enable-fastcgi --with-fpm-user=apache --with-fpm-group=apache --without-gdbm --disable-fileinfo  



--------------------------
Installing PHP SAPI module:       apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp7.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install install libphp7.la /usr/lib64/httpd/modules/
libtool: install: install .libs/libphp7.so /usr/lib64/httpd/modules/libphp7.so
libtool: install: install .libs/libphp7.lai /usr/lib64/httpd/modules/libphp7.la
libtool: install: warning: remember to run `libtool --finish /opt/project/php-7.0.0RC5/libs'
chmod 755 /usr/lib64/httpd/modules/libphp7.so
[activating module `php7' in /etc/httpd/conf/httpd.conf]
Installing shared extensions:     /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary:        /usr/local/php7/bin/
Installing PHP CLI man page:      /usr/local/php7/php/man/man1/
Installing phpdbg binary:         /usr/local/php7/bin/
Installing phpdbg man page:       /usr/local/php7/php/man/man1/
Installing PHP CGI binary:        /usr/local/php7/bin/
Installing PHP CGI man page:      /usr/local/php7/php/man/man1/
Installing build environment:     /usr/local/php7/lib/php/build/
Installing header files:          /usr/local/php7/include/php/
Installing helper programs:       /usr/local/php7/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php7/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php7/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.0
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.3.0
[PEAR] PEAR           - installed: 1.10.0
Wrote PEAR system config file at: /usr/local/php7/etc/pear.conf
You may want to add: /usr/local/php7/lib/php to your php.ini include_path
/opt/project/php-7.0.0RC5/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:          /usr/local/php7/include/php/ext/pdo/

--------------------------
/usr/bin/cp php.ini-production /usr/local/php7/etc/php.ini
/usr/bin/cp php.ini-production /etc/php.ini
/usr/bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
/usr/bin/cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
/usr/bin/cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R apache:apache php-fpm
mkdir -p /var/lib/php/session
chown -R apache:apache /var/lib/php/

chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
php-fpm -t
service php-fpm start

通过命令ps -aux|grep php查看是否成功(图中的php-fpm进程数和进程用户apache都是由www.conf中pm.start_servers和user的值分别决定的)
可以通过命令php -v查看当前PHP版本信息,图中可以看到当前PHP7还使用了Zend OPcache缓存,是因为在php.ini文件中添加了zend_extension=opcache.so配置。

# gedit /etc/php.ini      修改内容如下:
---------------
;extension=pdo_mysql.so
;extension=mysqli.so
;extension=mysql.so

mysqli.default_socket =/var/lib/mysql/mysql.sock
pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
short_open_tag = On
zend_extension=opcache.so
---------------

# gedit /etc/httpd/conf/httpd.conf      修改内容如下:
---------------
# LoadModule php5_module        /usr/lib64/httpd/modules/libphp5.so
LoadModule php7_module        /usr/lib64/httpd/modules/libphp7.so
FilesMatch \.php$>
SetHandler application/x-httpd-php
/FilesMatch>

---------------

php -v
php --ini

------------
MariaDB [(none)]> STATUS;
UNIX socket:        /var/lib/mysql/mysql.sock
------------

# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/pdo_mysql.so /usr/lib64/
# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/mysqli.so /usr/lib64/

# systemctl restart mariadb
# systemctl restart httpd

# php /var/www/html/index.php

# gedit /var/www/html/index.php

--------------------------------
?php
/*** mysql hostname ***/
$hostname = 'localhost';

/*** mysql username ***/
$DBusername = 'root';

/*** mysql password ***/
$DBpassword = '123456';

try {
    $dbh = new PDO("mysql:host=$hostname;dbname=mysql", $DBusername, $DBpassword);
    /*** echo a message saying we have connected ***/
    echo 'Connected to database';
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }
?>
--------------------------------
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(231) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-02-01 00:00  张同光  阅读(59)  评论(0编辑  收藏  举报