您的位置:首页 > 其它

阿里云服务器 ubuntu 12.4 安装workerman与3个简单开发实例测试

2016-09-05 10:15 417 查看
参考:http://doc3.workerman.net/getting-started/simple-example.html

1.apt-get install php5-cli git gcc php-pear php5-dev libevent-dev -y

2.pecl install event 安装过程出现问题

root@iZ252f8y3biZ:/# pecl install event

pecl/event requires PHP (version >= 5.4.0), installed version is 5.3.10-1ubuntu3.24

No valid packages found

install failed

3.git clone https://github.com/walkor/Workerman
4.创建http_test.php文件编写测试代码,将文件放到/var/www

运行命令:php /var/www/http_test.php start

Workerman[/var/www/http_test.php] start in DEBUG mode

----------------------- WORKERMAN -----------------------------

Workerman version:3.3.4          PHP version:5.3.10-1ubuntu3.24

------------------------ WORKERS -------------------------------

user          worker        listen               processes status

root          none          http://0.0.0.0:2345   4         [OK] 

----------------------------------------------------------------

Press Ctrl-C to quit. Start success.

在浏览器输入云服务器的公网ip以及端口号:http://123.56.29.115:2345/

返回:helloworld 说明配置成功

5.在ws_test.php使用时客户端,新建html文件:

<html>

<title></title>

<head>

<script>ws = new WebSocket("ws://123.56.29.115:2346");

ws.onopen = function() {

    alert("连接成功");

    ws.send('tom');

    alert("给服务端发送一个字符串:tom");

};

ws.onmessage = function(e) {

    alert("收到服务端的消息:" + e.data);

};

</script>

</head>

<body></body>

</html>

可以看到网页弹出框有提示说明正常连接

6.新建tcp_test.php 运行,通过tcp232-test软件:选择tcp客户端连接公网ip与端口号2347,连接成功之后发送可以收到服务器端返回来的数据
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: