


Detailed tutorial on how to install PHP's swoole extension, phpswoole installation method_PHP tutorial
Jul 12, 2016 am 08:52 AMDetailed 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擴(kuò)展。 請到swoole擴(kuò)展下載地址下載最新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擴(kuò)展:
extension=swoole.so
重啟php-fpm:
# service php-fpm restart
然后查看擴(kuò)展安裝情況。如果在列出的擴(kuò)展中看到了swoole,則說明安裝成功:
php -m
以上就是本文的全部內(nèi)容,希望對大家學(xué)習(xí)php程序設(shè)計(jì)有所幫助。

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To safely handle PHP file uploads, you need to verify the source and type, control the file name and path, set server restrictions, and process media files twice. 1. Verify the upload source to prevent CSRF through token and detect the real MIME type through finfo_file using whitelist control; 2. Rename the file to a random string and determine the extension to store it in a non-Web directory according to the detection type; 3. PHP configuration limits the upload size and temporary directory Nginx/Apache prohibits access to the upload directory; 4. The GD library resaves the pictures to clear potential malicious data.

InPHP,variablesarepassedbyvaluebydefault,meaningfunctionsorassignmentsreceiveacopyofthedata,whilepassingbyreferenceallowsmodificationstoaffecttheoriginalvariable.1.Whenpassingbyvalue,changestothecopydonotimpacttheoriginal,asshownwhenassigning$b=$aorp

The most direct way to find the last occurrence of a substring in PHP is to use the strrpos() function. 1. Use strrpos() function to directly obtain the index of the last occurrence of the substring in the main string. If it is not found, it returns false. The syntax is strrpos($haystack,$needle,$offset=0). 2. If you need to ignore case, you can use the strripos() function to implement case-insensitive search. 3. For multi-byte characters such as Chinese, the mb_strrpos() function in the mbstring extension should be used to ensure that the character position is returned instead of the byte position. 4. Note that strrpos() returns f

The reason why header('Location:...') in AJAX request is invalid is that the browser will not automatically perform page redirects. Because in the AJAX request, the 302 status code and Location header information returned by the server will be processed as response data, rather than triggering the jump behavior. Solutions are: 1. Return JSON data in PHP and include a jump URL; 2. Check the redirect field in the front-end AJAX callback and jump manually with window.location.href; 3. Ensure that the PHP output is only JSON to avoid parsing failure; 4. To deal with cross-domain problems, you need to set appropriate CORS headers; 5. To prevent cache interference, you can add a timestamp or set cache:f

To check whether Composer is installed correctly, first run the composer--version command to view the version information. If the version number is displayed, it means that it is installed. Secondly, use the composerdiagnose command to detect configuration problems and ensure that the environment variables and permissions are normal. Finally, try to verify the functional integrity through the composerrequiremonolog/monolog installation package. If the vendor directory is successfully created and the dependency is downloaded, it means that Composer is fully available. If the above steps fail, you may need to check whether PHP has been installed globally or adjusted system path settings.

AgeneratorinPHPisamemory-efficientwaytoiterateoverlargedatasetsbyyieldingvaluesoneatatimeinsteadofreturningthemallatonce.1.Generatorsusetheyieldkeywordtoproducevaluesondemand,reducingmemoryusage.2.Theyareusefulforhandlingbigloops,readinglargefiles,or

Use the installation media to enter the recovery environment; 2. Run the bootrec command to repair the boot records; 3. Check for disk errors and repair system files; 4. Disable automatic repair as a temporary means. The Windows automatic repair loop is usually caused by system files corruption, hard disk errors or boot configuration abnormalities. The solution includes troubleshooting by installing the USB flash drive into the recovery environment, using bootrec to repair MBR and BCD, running chkdsk and DISM/sfc to repair disk and system files. If it is invalid, the automatic repair function can be temporarily disabled, but the root cause needs to be checked later to ensure that the hard disk and boot structure are normal.

The COALESCE function is used to return the first non-null value in the parameter list and is suitable for processing NULL data. 1. The basic usage is to replace the NULL value, such as replacing the empty field with the default contact method; 2. It can be used to set the default value in aggregate query to ensure that 0 is returned instead of NULL when there is no data; 3. It can be used in conjunction with other functions such as NULLIF and IFNULL to enhance data cleaning and logical judgment capabilities.
