登录  /  注册
首页 > 后端开发 > PHP7 > 正文

介绍PHP7 源码安装 swoole 全流程

coldplay.xixi
发布: 2020-12-15 09:48:20
转载
1633人浏览过

php7/" target="_blank">PHP7教程栏目介绍如何源码安装swoole/" target="_blank">swoole

介绍PHP7 源码安装 swoole 全流程

推荐(免费):php7教程

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 8drwxr-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 functionsif [ -f ~/.bashrc ]; then . ~/.bashrc
fi
# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHalias php=/home/work/study/soft/php/bin/php//让配置生效[root@VM_0_5_centos php]#  source ~/.bash_profile 
[root@VM_0_5_centos php]# php -vPHP 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.php1585836787[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/
登录后复制

上传swoole文件包

[root@VM_0_5_centos softpackage]# rz[root@VM_0_5_centos softpackage]# ll
total 17076drwxrwxr-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 17080drwxrwxr-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:         20170718Zend Module Api No:      20170718Zend 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 80drwxr-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 9501tcp        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
登录后复制

本作品采用《CC 协议》,转载必须注明作者和本文链接

以上就是介绍PHP7 源码安装 swoole 全流程的详细内容,更多请关注php中文网其它相关文章!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
相关标签:
来源:简书网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
关于CSS思维导图的课件在哪? 课件
凡人来自于2024-04-16 10:10:18
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号