Home  >  Article  >  Backend Development  >  How to install swoole in php7

How to install swoole in php7

尚
Original
2019-12-06 11:17:312626browse

How to install swoole in php7

Compile & Install

cd swoole-src-2.0.6/,

1. Use phpize to generate php compilation configuration

2. Use ./configure to do compilation configuration detection

3.make to compile, make install to install

The command is executed as follows:

[root@php7 swoole-src-2.0.6]# phpize
[root@php7 swoole-src-2.0.6]# ./configure
[root@php7 swoole-src-2.0.6]# make && make install

4.make After installation, if it is correct, the following content will appear

[root@php7 swoole-src-2.0.6]# make install
Installing shared extensions:     /usr/lib64/php/modules/

Modify the configuration file

To be able to use this module, you also need to add the module in the php.ini file.

extension=swoole.so

Restart the service

After adding the php module, you need to restart the nginx and php-fpm services to take effect.

Finally check whether swoole is loaded successfully through php -m or phpinfo().

Note:

1.swoole_server can only be used in the php-cli environment, otherwise a fatal error will be thrown.

2. Therefore, you must use include_once or require_once when introducing a php file of a class/function, otherwise a fatal error of "cannot redeclare function/class" will occur.

3. Do not use exit()/die(), which will cause the worker process to exit.

4. If an exception is thrown in the PHP code, try/catch must be performed in the callback function to capture the exception, otherwise the worker process will exit.
Recommended: php FAQColumn

The above is the detailed content of How to install swoole in php7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn