Home  >  Article  >  php教程  >  【TECH】CAS php客户端配置

【TECH】CAS php客户端配置

WBOY
WBOYOriginal
2016-06-06 19:49:241337browse

搞完java又搞php,我整个人都不好了=。= 跟大师在linux上折腾了一下午,没调出来,早上在windows上跑通了,中午终于在linux上搞定了,嘿嘿。 server端配置参见这里 在windows上,我用的是xampp集成的Apache和PHP。 1.首先保证,php支持curl扩展,在xampp\php

搞完java又搞php,我整个人都不好了=。=

跟大师在linux上折腾了一下午,没调出来,早上在windows上跑通了,中午终于在linux上搞定了,嘿嘿。

server端配置参见这里

在windows上,我用的是xampp集成的Apache和PHP。

1.首先保证,php支持curl扩展,在xampp\php\php.ini中保证;extension=php_curl.dll前面的;去掉。

2.到CAS的github上下载php client代码。

3.我的xampp工程的路径就是xampp\htdocs这个路径,这个可以在D:\xampp\apache\conf\httpd.conf中配置。所以在xampp\htdocs\下新建一个文件夹叫Phpcasclient1,将刚才下载的压缩包里面的CAS.php和CAS文件夹拷贝到Phpcasclient1中。并且把压缩包里面的\docs\examples\example_simple.php也拷贝过去。

4.定位到example_simple.php中的

phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);

把后面三项分别设置为对应的cas server网址,端口和工程名称,我访问我的cas server的时候是通过网址https://sunshineatnoon.com:8443/cas/login访问的,其中sunshineatnoon.com是我的服务器域名,可以改成对应的ip地址或者localhost。所以我的client函数配置如下:

phpCAS::client(CAS_VERSION_2_0, 'sunshineatnoon.com',8443, 'cas');

特别注意example_simple.php中的这一行代码:

<span>require_once</span> <span>$phpcas_path</span> . '/CAS.php';

通过这一行代码,example_simple.php要能够找到CAS.php这个文件,因为刚刚我把这个文件放在了example_simple.php同一个文件夹里面,所以我把上一行代码改成了:

<span>require_once</span> '/CAS.php';

当然,为了保险,可以直接写CAS.php的绝对路径,在下文linux的配置下就可以看到这一点非常重要。

5.这时就可以通过浏览器访问php client端了,输入网址:http://localhost/Phpcasclient1/example_simple.php就可以看到cas的跳转页面了:

 【TECH】CAS php客户端配置

用数据库里面的用户名密码登录后,就看到了client真实的页面了:

【TECH】CAS php客户端配置

我看网上大部分的教程都需要安装php的pear和db扩展,我这里没有安装,但是确实收到了以下两条warning:

<span>1</span> Warning: <span>require</span>(script_info.php): failed to open stream: No such <span>file</span> or directory in D:\xampp\htdocs\Phpcasclient1\example_simple.php on line 56
 
2 Fatal error: <span>require</span>(): Failed opening required 'script_info.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\Phpcasclient1\example_simple.php on line 56

因为不会php =。=,所以就不细致研究了。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn