使用PHP+Swoole实现的网页即时聊天,中高级程序员进阶学习
蘑菇宝
蘑菇宝 2018-12-06 13:44:53
0
0
1395

将client目录配置到Nginx/Apache的虚拟主机目录中,使client/index.html可访问。修改client/config.js中,IP和端口为对应的配置。 php webim_server.php 详细部署说明 1.安装composer(php依赖包工具)

curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer 注意:如果未将php解释器程序设置为环境变量PATH中,需要设置。因为composer文件第一行为#!/usr/bin/env php,并不能修改。

2.composer install

切换到PHPWebIM项目目录,执行指令composer install,如很慢则

composer install --prefer-dist 3.Ningx/Apache配置(这里未使用swoole_framework提供的Web AppServer)

nginx

server
{
    listen       80;
    server_name  im.swoole.com;
    index index.shtml index.html index.htm index.php;
    root  /path/to/PHPWebIM/client;
    location ~ .*\.(php|php5)?$
    {
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
    access_log  /Library/WebServer/nginx/logs/im.swoole.com  access;
}

apache

<VirtualHost *:80>
    DocumentRoot "path/to/PHPWebIM/client"
    ServerName im.swoole.com
    AddType application/x-httpd-php .php
    <Directory />
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        DirectoryIndex index.php
    </Directory>
</VirtualHost>

4.修改配置PHPWebIM/config.php

$config['server'] = array(
    //监听的HOST
    'host' => '0.0.0.0',
    //监听的端口
    'port' => '9503',
    //WebSocket的URL地址,供浏览器使用的
    'url' => 'ws://127.0.0.1:9503',
);

server.host server.port 项为WebIM服务器即WebSocket服务器的IP与端口,其他选择项根据具体情况修改 server.url对应的就是服务器IP或域名以及websocket服务的端口,这个就是提供给浏览器的WebSocket地址 webim.data_dir用于修改聊天记录存储的目录,必须有可写权限 

5.启动WebSocket服务器 php PHPWebIM/webim_server.php IE浏览器不支持WebSocket,需要使用FlashWebSocket模拟,请修改flash_policy.php中对应的端口,然后启动flash_policy.php。 php PHPWebIM/flash_policy.php 6.绑定host与访问聊天窗口(可选) 如果URL直接使用IP:PORT,这里不需要设置。 vi /etc/hosts 增加 127.0.0.1 im.swoole.com 用浏览器打开:http://im.swoole.com 


蘑菇宝
蘑菇宝

精品PHP中高级进阶学习教程,需要加微信:PHPopen888,还可加入微信群,分享tp,laravel,swoole等...

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!