preface

Yesterday, in the local installation Swoole debugging environment, met several pit, because my computer is Windows, so install cygwin, but the process is not smooth, have problems installing terminal, step by step, and check information pit, finally also smooth installation is successful, in order to let the others will one-time installation is successful, Save a lot of trouble trouble, I specially wrote this article, hope to have help to the people in need.

Download Swoole

Swoole download: github.com/swoole/swoo…

Open the download address in the browser, slide to the download location, you can download the zip file or tar.gz file package, wait for later.

Download the cygwin

Cygwin can be downloaded from www.cygwin.com/

Open the Cygwin official website in a browser, go to Installing Cygwin and click setup-x86_64.exe to download the EXE file

Install cygwin

Find the setup-x86_64.exe file you just downloaded, double-click it to open it and start installing Cygwin

  • Step 1: Open the installation interface and click Next

  • Step 2: Select the download source, we directly choose the defaultInstall from InternetAnd click Next

  • Step 3: Select the installation directory, you can directly modify the installation directory in the input box, or clickBrowseSelect a directory and click Next

  • Step 4: Select the package download directory, you can directly modify the directory in the input box, or clickBrowseSelect a directory and click Next

  • Step 5: Select the web server, default directly on the line, click continue next

  • Step 6: Choose a download server url, we choosehttp://mirrors.metapeer.comHere, we can also add the download server of 163 by ourselves, the address ishttp://mirrors.163.com/cygwin/To proceed to the next step

  • Step 7: Select the software package you want to install.ViewThe drop-down choiceCategoryoptions

  • Step 8: Search and select the software package you want to install

Gcc-core, Search gcc-core in Search, expand Devel, find the blue check item in the following figure, double-click on the New column to select it

Search for PHP and php-devel in Search, open Interpreters, and find the blue option shown in the following figure. Double-click the New bar to select it. Remember to select PHP and php-devel

Libpcre-devel, Search libpcre-devel in Search, expand Libs, find the blue option in the image below, double-click on the New column and select it

Autoconf-archive, Search autoconf-archive in Search, expand Devel, find the blue option in the following figure, double-click in the New column and select it

Gcc-objc ++, Search for gcc-objC ++ in Search, expand Devel, find the blue option in the following figure, double-click on the New bar and select it

Libc++ -devel, Search libc++-devel in Search, expand devel, find the blue option in the following figure, double-click in the New column and select it

Libc++ 1, Search for libc++1 in Search, expand Devel, find the blue option in the image below, double-click in the New column and select it

PHP -json, Search PHP -json in Search, expand PHP, find the blue option in the following image, in the New column, double click to select

Pcre2, Search for pcre2 in Search, expand Text, find the blue selection in the picture below, double-click in the New column to select

Libpcre2-devel, Search libpcre2-devel in Search, expand Libs, find the blue option in the image below, double-click on the New column and select it

  • Finally, select the complete package, click Next, until the installation is complete, the time may be a little long, wait patiently

Compile and install Swoole

  • Unzip and place in the home directory

Unzip the Swoole package and place it in cygwin’s home directory. For convenience, rename it Swoole, but leave it there

  • Open Cygwin and go to the Swoole directory

Double-click to run the Cygwin software, and then go to the source code Swoole unzipped by using the command CD /home/swool/

  • Generate the compiled configuration file

In Swoole’s root directory, execute the command phpize to generate the compiled configuration file configure

  • Compile the configuration and inspect the environment and compile the installation

/configure && make && make install, and wait for the Swoole installation to complete

Check whether the Swoole installation is successful

  • Check to see if the Swoole extension is enabled

Ini configuration file is in /etc/php.ini. Then you can use vi editing to look at vi /etc/php.ini and go to the last line of the file. There is already a line of extension configuration with extension=swoole.dll because the module was compiled into PHP at compile install time.

We then check to see if there is a swoole extension by calling php-m. As you can see from the following figure, there is a Swoole extension

Test the Swoole environment

  • Select and go to the test directory

In the Swoole source code that we downloaded, there are many examples that we can run directly to test, go to the examples directory, which is full of sample code, select HTTP /server.php to test, and then CD HTTP/to go to the HTTP directory

  • Executing the PHP program

PHP: PHP server: PHP server: PHP server: PHP server: PHP

  • Browser running tests

$HTTP = new swoole_http_server(“0.0.0.0”, 9501); , the port for starting swoole service is 9501, so we can directly enter 127.0.0.1:9501 or localhost:9501 in the browser address bar and access it, and the display “Hello Swoole.” shows that swoole is successfully installed!

conclusion

As long as according to the article step by step installation, should be able to one-time installation success, because I step by step a pit stepped over, and have filled the pit, do not boast me, will be proud. During the installation process, if you have any questions, please leave a message to me directly. I will reply and help you solve them in time. If you have other better ideas, I will analyze them and communicate with you.