官网下载
https://www.php.net/releases/
安装步骤
默认方式
tar -xjvf php-7.2.2.tar.bz2
cd php-7.2.2
sudo yum install libxml2
yum install libxml2-devel -y
./configure
make
make install
whereis php
[root@localhost etc]# php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/lib
cd /usr/local/lib
sudo cp /home/work/study/softpackage/php-7.2.2/php.ini-development ./
sudo mv php.ini-development php.ini
[root@localhost lib]# ls
php php.ini python3.6
<?php
echo 1;
echo "\n";
指定安装目录方式【–prefix指定make installl时的软件安装位置】
tar -zxvf php-8.1.16.tar.gz
yum -y install sqlite-devel
./configure --prefix=/home/work/study/soft/php
make
make install
#查看版本
/home/work/study/soft/php/bin/php --version
简化命令
sudo vim ~/.bash_profile
alias php8=/home/work/study/soft/php/bin/php
刷新
source ~/.bash_profile
[root@localhost php-8.0.28]# php8 -i | grep php.ini
Configuration File (php.ini) Path => /home/work/study/soft/php/lib
[root@localhost php-8.0.28]# sudo cp php.ini-development /home/work/study/soft/php/lib
[root@localhost php-8.0.28]# cd /home/work/study/soft/php/lib
[root@localhost lib]# ls
php php.ini-development
[root@localhost lib]# sudo mv php.ini-development php.ini
[root@localhost lib]# ls
php php.ini
[root@localhost lib]#
swoole下载
https://gitee.com/swoole/swoole/tree/v5.0.0/
安装
【其实phpize是一个运行脚本,主要作用是检测php的环境还有就是在特定的目录生成相应的configure文件,这样makeinstall之后,生成的.so文件才会自动加载到php扩展目录下面。
configure
configure文件其实就是个shell脚本,phpize会把检测的php环境信息放到configure里面
】
[root@localhost swoole-v5.0.0]# pwd
/root/Desktop/swoole/swoole-v5.0.0
[root@localhost swoole-v5.0.0]# /home/work/study/soft/php/bin/phpize
[root@localhost swoole-v5.0.0]# yum install gcc-c++
[root@localhost swoole-v5.0.0]# ./configure --with-php-config=/home/work/study/soft/php/bin/php-config
[root@localhost swoole-v5.0.0]# make
[root@localhost swoole-v5.0.0]# make install
Installing shared extensions: /home/work/study/soft/php/lib/php/extensions/no-debug-non-zts-20200930/
Installing header files: /home/work/study/soft/php/include/php/
[root@localhost swoole-v5.0.0]# cd /home/work/study/soft/php/lib/php/extensions/no-debug-non-zts-20200930/
[root@localhost no-debug-non-zts-20200930]# ll
总用量 38224
-rwxr-xr-x. 1 root root 5563232 2月 19 22:18 opcache.so
-rwxr-xr-x. 1 root root 33574752 2月 19 22:41 swoole.so
[root@localhost lib]# pwd
/home/work/study/soft/php/lib
[root@localhost lib]# ll
总用量 72
drwxr-xr-x. 4 root root 37 2月 19 22:18 php
-rw-r--r--. 1 root root 72384 2月 19 22:31 php.ini
[root@localhost lib]# sudo vim php.ini
extension=swoole
[root@localhost ~]# netstat -anp | grep 9501
tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 53156/php