Environment configuration of swoole on mac os

     I have been working on mobile clients, but a real project cannot be accomplished with only the client, so I decided to learn server development. I used to know the servlet development method using java, but now I find that this method seems a bit outdated. Nowadays, many frameworks are used for rapid development, and I also need to build a server framework more quickly, so I searched for convenient open source on the Internet. Application or game server framework, finally found a php web server and application server based on swoole extension .

     I am currently using mac pro for development, so I need to install swoole's php extension on the mac machine. So now let's take a look at how to configure the swoole environment on the mac.

1. The current development environment:

System version: mac os x 10.9.4

php version: php 5.4.24

mysql version: mysql 5.5.28

2. Configuration process

1. First, open the official swoole webpage: http://www.swoole.com . There are documents and video tutorials on the official webpage for configuration.

2. Download the latest version of swoole, open https://github.com/swoole/swoole-src/releases , the stable version swoole-1.7.13-stable I chose to download

3. At this time, you can refer to http://wiki.swoole.com/wiki/page/6.html in the document for configuration.

4. I chose the recommended method

cd swoole
phpize
./configure
make 
sudo make install

a. But when encountering the first problem in phpize, look at the error message again, ./configure: No such file or directory, no configure file was generated. Find the reason is that autoconf is not installed. Then you need to install autoconf, Baidu found that you need to install Homebrew first;

b. brew, also known as Homebrew, is a software package management tool on Mac OSX. It can easily install or uninstall software on Mac with only one command. brew is similar to the function of apt-get under the ubuntu system, so how to install brew? Open the command line and enter the command

curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo tar xvz -C/usr/local --strip 1

That's it. Brew -v can view the information of the installed brew;

c. At this time, autoconf can be installed. Enter the command brew install autoconf, but an error will be reported at this time, so just add a sudo in front, and enter the command

sudo brew install autoconf

Wait for a while, the autoconf installation is complete, at this time you can execute the phpize command again, and you can see that several files have been generated, including the configure file;

d. Continue to execute the command

./configure

e. Execute the command again

make

At this time, I encountered the compilation problem fatal error: 'php.h' file not found again, and looked for a solution again. At this time, I need to use Xcode. Connect the include folder in Xcode to /usr/include, and you can use it Order

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include /usr/include

地址可以右键点击xcode图标,选择显示包内容,然后根据上诉地址查找到相对应的include地址,其中MacOSX10.8.sdk为自己的地址,可能需要修改,如果出现找不到文件夹/usr/include的情况的话,那么可以给xcode安装命令行Command Line Tool工具,可以使用命令行方式安装,命令

xcode-select --install

f、之后再次出现报错fatal error: 'pcre.h' file not found,原因是由于缺少了pcre开发包所导致的,那么就需要安装pcre包,根据上面的经验,我选择使用sudo brew install pcre试试,安装成功,如果有问题只要保证/usr/include文件夹中有需要的h文件即可;

    g、这个时候重新进行make,成功通过;

 h、接着

sudo make install 

成功;

i、这个时候需要给php添加扩展了,命令行输入

cd /private/etc

open .

打开文件夹,可以看到php.ini文件没有的话将php.ini.default文件拷贝一份修改名字为php.ini即可。

j、修改php.ini文件,添加extension=swoole.so,重启php服务或者注销等操作之后,就可以通过php -m或phpinfo()来查看是否成功加载了swoole扩展。

好了这个时候就能在php代码中使用swoole框架了。


参考资料:

http://blog.csdn.net/sqc3375177/article/details/23662755

http://blog.sina.com.cn/s/blog_48d40b7a0101h2zj.html

http://wangye.org/blog/archives/313/

http://www.jb51.net/os/MAC/101860.html

http://blog.csdn.net/dracotianlong/article/details/21816543

http://www.phperz.com/article/15/0102/42077.html

http://www.swoole.com

http://wiki.swoole.com/wiki/page/1.html


Guess you like

Origin blog.csdn.net/rsp19801226/article/details/44590803