This article mainly shares a detailed tutorial on swoole extension installation method in PHP, which is practical and useful for reference. if you are interested, refer to Swoole's support for PHP 5.3.10 or later versions, therefore, install PHP 5.3.10 or later before installing Swoole. now we will introduce how to install and configure PHP in Windows.
Software version:Php-5.3.1-Win32-VC6-x86.zip
This does not require additional installation of the. net library, so it is used. You can use another one.
1. PHP installation
Download the Zip file in green and decompress it.
2. configuration
Find php. ini-development in the extracted root directory, which is the configuration file used for the development environment. There is also a php. ini-production, which is the configuration file used for the production environment. Use php. in-development to copy a copy and rename it to php. ini. Start editing.
Locate registe_globals = Off;
We recommend that you do not 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']" to obtain the sent Value. if it is set to "On ", you can directly use the "$ variable name" to obtain the sent Value. of course, setting it to "Off" is safer, so that data transmitted between webpages is not intercepted easily. If this value is changed to "On", it depends On your own feeling. is it important for security or convenience?
To enable php to call other modules, you can search by the extension keyword, locate the following, remove the semicolon before the option, and enable the support of this module.
The more modules are loaded, the more resources are occupied, which can be ignored. For example, to enable mysql support, find the following
; Extension = php_mysql.dll
Remove the preceding ";" comment.
All modules are placed in the ext directory under the php decompression directory, which can be enabled as needed.
Error in loading module:
Sometimes, when Apache is started, the error "the specified module cannot be found" is prompted because the location of these module files is not specified and the keyword "extension_dir" is located ", modify the directory of your PHP module in Windows.
For example, if my PHP directory is in D: \ PHP, configure
Extession_dir = "D: \ PHP \ ext"
In this way, no error is reported when Apache is started.
This section describes the simplest method. you can directly specify the php Installation Path and the ext path in it to the windows system path-right-click "My Computer" and select "properties ", select the "Advanced" tab, click "environment variables", find the "Path" variable under "system variables", Select, double-click or click "edit", and D: \ php; D: \ php \ ext "is added after the original value. of course," D: \ php "is my installation directory, change it to your php installation directory, as shown in.
3. work with Apache
Php combines modules with Apache to open the configuration file of Apache and locate the module to be loaded with the keyword "LoadModule,
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" indicates loading php in module mode, and the second line "PHPIniDir" D:/php "indicates the php configuration file php. the ini location is, of course, where "D:/php" should be changed to the directory you have previously selected for php decompression.
Php5apache2. dll and php5apache2_2.dll are included in the php decompression Directory. because our apache version is 2.2, we load the dll.
You can configure php5apache2_2.dll as needed.
Search by the keyword AddType application. you can define the php file type that can be executed,
Original article: 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.pdf", The .htm file can also execute the php program. you can even add the last line "AddTypeapplication/x-httpd-php. txt, so that common text txt can also run php programs.
The basic configuration of PHP is complete.
How to install swoole extension in PHP:
Put php into environment variables after installation
# export PATH=/usr/local/php/bin:$PATH # export PATH=/usr/local/php/sbin:$PATH
After saving, enter the following command on the terminal:
# source ~/.bashrc
Then you can install the swoole extension. Go to the swoole extension to download the latest stable version. This article takes 1.8.5 as an example:
# 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
Then add the Swoole extension to the php. ini file:
extension=swoole.so
Restart php-fpm:
# service php-fpm restart
Then, view the extension installation information. If swoole is seen in the listed extensions, the installation is successful:
php -m
The above is all the content of this article. I hope it will help you learn php programming.