PHP7 源码安装
步骤
1、解压 tar -xjvf
2、configure
3、make
4、make install
安装上传下载命令
yum install -y lrzsz
linux 操作
[root@VM_0_5_centos ~]# cd /home/ [root@VM_0_5_centos home]# mkdir -p work/study/softpackage [root@VM_0_5_centos softpackage]# pwd /home/work/study/softpackage [root@VM_0_5_centos softpackage]# ll total 14900 -rw-r--r-- 1 root root 15235268 Apr 2 21:19 PHP-7.2.29.tar.bz2 [root@VM_0_5_centos softpackage]# tar -xjvf PHP-7.2.29.tar.bz2 drwxrwxr-x 14 root root 4096 Mar 17 18:16 PHP-7.2.29 -rw-r--r-- 1 root root 15235268 Apr 2 21:19 PHP-7.2.29.tar.bz2 [root@VM_0_5_centos softpackage]# cd PHP-7.2.29/ [root@VM_0_5_centos PHP-7.2.29]# yum install gcc ---- configure: error: libxml2 not found. Please check your libxml2 installation. ---- //start安装豪华套餐 yum -y install gcc libxml2 yum -y install PHP-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel //end [root@VM_0_5_centos PHP-7.2.29]# ./configure --prefix=/home/work/study/soft/PHP [root@VM_0_5_centos PHP-7.2.29]# make [root@VM_0_5_centos PHP-7.2.29]# make install [root@VM_0_5_centos PHP-7.2.29]# cd /home/work/study/ [root@VM_0_5_centos study]# ll total 8 drwxr-xr-x 3 root root 4096 Apr 2 22:04 soft drwxr-xr-x 3 root root 4096 Apr 2 21:44 softpackage [root@VM_0_5_centos study]# cd soft/PHP/ [root@VM_0_5_centos PHP]# [root@VM_0_5_centos PHP]# ./bin/PHP -m //测试 [root@VM_0_5_centos PHP]# vim test.PHP [root@VM_0_5_centos PHP]# ./bin/PHP test.PHP 1585836467[root@VM_0_5_centos PHP]# //编辑 [root@VM_0_5_centos PHP]# vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH alias PHP=/home/work/study/soft/PHP/bin/PHP //让配置生效 [root@VM_0_5_centos PHP]# source ~/.bash_profile [root@VM_0_5_centos PHP]# PHP -v PHP 7.2.29 (cli) (built: Apr 2 2020 22:03:18) ( NTS ) copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0,copyright (c) 1998-2018 Zend Technologies //测试 [root@VM_0_5_centos study]# mkdir demo [root@VM_0_5_centos study]# cd demo/ [root@VM_0_5_centos demo]# vim t.PHP [root@VM_0_5_centos demo]# PHP t.PHP 1585836787[root@VM_0_5_centos demo]# pwd /home/work/study/demo
转移 PHP.ini
[root@VM_0_5_centos study]# cd softpackage/PHP-7.2.29/ [root@VM_0_5_centos PHP-7.2.29]# pwd /home/work/study/softpackage/PHP-7.2.29 [root@VM_0_5_centos PHP-7.2.29]# cp PHP.ini-development /home/work/study/soft/PHP/etc/ [root@VM_0_5_centos ~]# cd /home/work/study/soft/PHP/etc/ [root@VM_0_5_centos etc]# ll total 80 -rw-r--r-- 1 root root 1354 Apr 2 22:05 pear.conf -rw-r--r-- 1 root root 71232 Apr 2 22:17 PHP.ini-development [root@VM_0_5_centos etc]# mv PHP.ini-development PHP.ini [root@VM_0_5_centos PHP-7.2.29]# PHP -i | grep PHP.ini Configuration File (PHP.ini) Path => /home/work/study/soft/PHP/lib [root@VM_0_5_centos PHP-7.2.29]# cd /home/work/study/soft/PHP/ [root@VM_0_5_centos PHP]# mv ./etc/PHP.ini ./lib/
[root@VM_0_5_centos softpackage]# rz [root@VM_0_5_centos softpackage]# ll total 17076 drwxrwxr-x 17 root root 4096 Apr 2 21:55 PHP-7.2.29 -rw-r--r-- 1 root root 15235268 Apr 2 21:19 PHP-7.2.29.tar.bz2 -rw-r--r-- 1 root root 2217161 Apr 2 22:27 swoole-swoole-master.zip [root@VM_0_5_centos softpackage]# unzip swoole-swoole-master.zip [root@VM_0_5_centos softpackage]# ll total 17080 drwxrwxr-x 17 root root 4096 Apr 2 21:55 PHP-7.2.29 -rw-r--r-- 1 root root 15235268 Apr 2 21:19 PHP-7.2.29.tar.bz2 drwxr-xr-x 9 root root 4096 Jan 9 20:06 swoole -rw-r--r-- 1 root root 2217161 Apr 2 22:27 swoole-swoole-master.zip //生成configure文件 [root@VM_0_5_centos swoole]# /home/work/study/soft/PHP/bin/PHPize Configuring for: PHP Api Version: 20170718 Zend Module Api No: 20170718 Zend Extension Api No: 320170718 [root@VM_0_5_centos swoole]# ./configure --with-PHP-config=/home/work/study/soft/PHP/bin/PHP-config checking how to run the C++ preprocessor... /lib/cpp configure: error: in `/home/work/study/softpackage/swoole': configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details //说明 error: C++ preprocessor "/lib/cpp" fails sanity check 问题的解决 问题的根源是缺少必要的C++库。如果是CentOS系统,运行,如下命令解决: yum install glibc-headers yum install gcc-c++
再执行
[root@VM_0_5_centos swoole]# ./configure --with-PHP-config=/home/work/study/soft/PHP/bin/PHP-config [root@VM_0_5_centos swoole]# make [root@VM_0_5_centos swoole]# make install [root@VM_0_5_centos swoole]# cd /home/work/study/soft/PHP/lib/PHP/extensions/no-debug-non-zts-20170718/ [root@VM_0_5_centos no-debug-non-zts-20170718]# ll total 17664 -rwxr-xr-x 1 root root 3589814 Apr 2 22:04 opcache.a -rwxr-xr-x 1 root root 1979620 Apr 2 22:04 opcache.so -rwxr-xr-x 1 root root 12488337 Apr 2 22:41 swoole.so [root@VM_0_5_centos lib]# ll total 80 drwxr-xr-x 15 root root 4096 Apr 2 22:05 PHP -rw-r--r-- 1 root root 71232 Apr 2 22:17 PHP.ini [root@VM_0_5_centos lib]# vi PHP.ini [root@VM_0_5_centos lib]# pwd /home/work/study/soft/PHP/lib 在PHP.ini文件中添加:extension=swoole.so 查看是否添加成功:PHP -m [root@VM_0_5_centos server]# PHP echo.PHP ^C [root@VM_0_5_centos server]# pwd /home/work/study/softpackage/swoole/examples/server //新开窗口 [root@VM_0_5_centos server]# netstat -anp|grep 9501 tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 23406/PHP [root@VM_0_5_centos server]# netstat -anp|grep 9501 [root@VM_0_5_centos server]# pwd /home/work/study/softpackage/swoole/examples/server
更多学习内容请访问:
腾讯T3-T4标准精品PHP架构师教程目录大全,只要你看完保证薪资上升一个台阶(持续更新)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。