Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install PHP7.2.4 with source code and add swoole2.1.1 extension to CentOS

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "CentOS how to install PHP7.2.4 with source code and add swoole2.1.1 extension". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

installation environment

centos 7.4

php 7.2.4

swoole 2.1.1

In the next step, I will use the Jingdong cloud host with centos 7.4 system installed to demonstrate for you

The code package is as follows

[root@JD ~]# pwd/root[root@JD ~]# lsmysoft work[root@JD ~]# cd mysoft/[root@JD mysoft]# lsphp-7.2.4.tar.bz2 swoole-swoole-v2.1.1.zip[root@JD mysoft]#

Source code installation php

tar -jxvf php-7.2.4.tar.bz2 extract php-7.2.4.tar.bz2 directory

● cd php-7.2.4/Enter php-7.2.4.tar.bz2 directory

● mkdir /usr/local/src/php7.2.4 New php installation directory

● ./ configure --prefix=/usr/local/src/php7.2.4 Check configuration

If the error below is reported because gcc is not installed, use yum install gcc* to install it

checking for cc... nochecking for gcc... noconfigure: error: in `/root/mysoft/php-7.2.4':configure: error: no acceptable C compiler found in $PATHSee `config.log' for more details

● If error: libxml2 not found rpm -qa| grep libxml2 Check if libxm package is installed

yum install libxml2-devel

● If there is no yum install libxml2 then yum install libxml2-devel

make && make install takes longer to compile

Let's test this by creating a hello.php with the output hello world!

[root@JD ~]# vim hello.php[root@JD ~]# /usr/local/src/php7.2.4/bin/php hello.php hello world! [root@JD ~]#

runs successfully

If we use php hello.php directly, the system will report an error-bash: php: command not found

vim ~/.bash_profile Add php alias as follows

export PATHalias php=/usr/local/src/php7.2.4/bin/php

Don't forget to source ~/.bash_profile again

Now you can run php code directly using php hello.php

Now you may think that your php installation is successful, but you will find a fatal problem: you can not find the php.ini file

[root@JD ~]# find / -name php.ini[root@JD ~]#

To install the source code, we need to copy the php.ini file in the source package to our installation directory

So where do we copy it? We can use php -i.| grep php.ini

[root@JD php-7.2.4]# php -i |grep php.iniConfiguration File (php.ini) Path => /usr/local/src/php7.2.4/lib

We can see what we need to copy to the lib directory

Use the command cp php. ini-development/usr/local/src/php7.2.4/lib/php.ini

Copy successful

PHP 7.2.4 has been installed successfully.

Source code installation swoole

● unzip swoole-swoole-v2.1.1.zip unzip swoole

● cd swoole/enter swoole directory

● /usr/local/src/php7.2.4/bin/phpize generate configure file

Cannot find autoconf. Use the command yum install autoconf to install

● ./ configure --with-php-config=/usr/local/src/php7.2.4/bin/php-config

● make && make install to compile

Add extension=swoole.so to the last line of php.ini after compilation

● php -m |grep swoole Find out if swoole was installed successfully

[root@JD lib]# php -m |grep swooleswoole

swoole installed successfully

Try using swoole with php

swoole source package has a lot of swoole demo for example swoole/examples/server directory has an echo.php;

echo.php turns on tcp service and listens on port 9501;

netstat -anp |grep 9501 We check that port 9501 is not currently occupied;

[root@JD lib]# netstat -anp |grep 9501[root@JD lib]#

php echo.php Now we run echo.php;

Check again that port 9501 has been occupied by php;

[root@JD lib]# netstat -anp |grep 9501tcp 0 0 0.0.0.0:9501 0.0.0.0:* LISTEN 27728/php

A simple service of our swoole has now been turned on.

You can use swoole to develop happily later.

"CentOS how to install PHP7.2.4 with source code and add swoole2.1.1 extension" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report