search
HomeBackend DevelopmentPHP TutorialDetailed tutorial on how to install PHP's swoole extension, phpswoole installation method_PHP tutorial

Detailed tutorial on the installation method of PHP's swoole extension, phpswoole installation method

Swoole supports PHP 5.3.10 or above, so please install PHP 5.3.10 or above before installing Swoole. Now let’s introduce the installation and configuration method of PHP under Windows.

Software version: php-5.3.1-Win32-VC6-x86.zip

This does not require additional installation of .net libraries, so this is used. Others can be used.

1.PHP installation

Use the green method to download the Zip file and extract it.

2. Configuration

In the root directory of the decompression, find php.ini-development, which is a configuration file for the development environment; there is also a php.ini-production, which is a configuration file for the production environment. Using php.in-development, make a copy and rename it to php.ini. Start editing.

Location registe_globals =Off;

It is recommended not to open it. The difference is that this value is used to open global variables, such as the value sent from the form. If this value is set to "Off", you can only use "$_POST['variable name'], $ _GET['variable name']" and so on to get the sent value. If it is set to "On", you can directly use "$variable name" to get the sent value. Of course, it is safer to set it to "Off". No one can easily intercept the data transmitted between web pages. Whether this value is changed to "On" depends on your own feeling. Is safety or convenience more important?

In order to enable php to call other modules, you can search with the extension keyword and locate as follows. Remove the semicolon before the option to open support for this module.

The more modules loaded, it will occupy slightly more resources, which can be ignored. For example, to enable mysql support, find the following

;extension=php_mysql.dll

Just remove the ";" comment in front.

All modules are placed in the ext directory under the PHP decompression directory and can be enabled as needed.

Error when loading module:

Sometimes when starting Apache, the error "The specified module cannot be found" will be prompted. This is because the location of these module files is not specified. Locate the keyword "extension_dir" and modify the directory for your PHP module under Windows.

For example, if my PHP directory is in D:PHP, then configure

exession_dir = "D:PHPext"

This way there will be no error when starting Apache.

Here is the simplest method to directly specify the PHP installation path and the ext path inside it to the Windows system path - right-click on "My Computer", "Properties", select the "Advanced" tab, and click Select "Environment Variables", find the "Path" variable under "System Variables", select it, double-click or click "Edit", and add ";D:php;D:phpext" to the end of the original value. Of course, the "D:php" is my installation directory. You need to change it to your own php installation directory, as shown in the figure below, confirm everything.

3. Work with Apache

php is combined with Apache in module mode, open Apache's configuration file, locate it with the keyword "LoadModule", and configure the module to be loaded,

Add the following two lines at the end:

LoadModule php5_module D:/php/php5apache2_2.dll

PHPIniDir "D:/php"

The first line "LoadModule php5_module D:/php/php5apache2_2.dll" refers to loading PHP in module mode, and the second line "PHPIniDir "D:/php"" indicates the location of PHP's configuration file php.ini. Of course, "D:/php" needs to be changed to the directory where php is decompressed that you selected previously.

There are both php5apache2.dll and php5apache2_2.dll in the php decompression directory. Because our apache version is 2.2, the dll is loaded

Use php5apache2_2.dll and configure it according to your own situation.

Search with the keyword AddType application to define the file type that can execute php,

The original text is as follows: AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.

Join

AddType application/x-httpd-php .php

AddTypeapplication/x-httpd-php.html

Two lines, you can also add more. The essence is to add file types that can execute php. For example, if you add a line "AddTypeapplication/x-httpd-php .htm", then the .htm file can also execute php programs. , you can even add the previous line "AddTypeapplication/x-httpd-php .txt" so that ordinary text txt can also run php programs.

The basic configuration of PHP is completed.

Continue to introduce the PHP swoole extension installation method:

After the installation is complete, put php into the environment variable

# export PATH=/usr/local/php/bin:$PATH 
# export PATH=/usr/local/php/sbin:$PATH

After saving, enter the command in the terminal:

# source ~/.bashrc

然后即可安装swoole扩展。 请到swoole扩展下载地址下载最新stable版本, 本文以1.8.5为例:

# wget https://github.com/swoole/swoole-src/archive/swoole-1.8.5-stable.tar.gz
# tar zxvf swoole-1.8.5-stable.tar.gz
# cd swoole-1.8.5-stable
# phpize 
# ./configure 
# make && make install

然后在php.ini文件添加Swoole扩展:

extension=swoole.so

重启php-fpm:

# service php-fpm restart

然后查看扩展安装情况。如果在列出的扩展中看到了swoole,则说明安装成功:

php -m

以上就是本文的全部内容,希望对大家学习php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1127848.htmlTechArticlePHP的swoole扩展安装方法详细教程,phpswoole安装方法 Swoole支持PHP 5.3.10以上版本,所以安装Swoole之前请先安装PHP 5.3.10以上版本,现在来介绍...
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
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor