我试图通过CodeIgniter的Hello World教程,但无法得到适当的结果。我在Ubuntu 10.10和apache2上运行。我怀疑,权限有问题,但不知道如何解决。我做了什么:
- 安装apache2、php5、mysql等
- Apache将web目录设置为/var/www,这没有必要的权限,所以我要做的下一件事是
sudo chmod 777 /var/www
。 - 将"默认"apache站点配置中的AllowOverride None更改为AllowOverride All。
- 复制ci到www, localhost/ci/给我"禁止"。您没有访问此服务器上的/ci/的权限。"
- sudo chmod a+rwx/。localhost/ci/ works, localhost/ci/index.php/user_guide/ works, localhost/ci/index.php/blog/index/返回404 (ci 's), localhost/ci/index.php/blog/index/ - 404 (ci 's!)
- 正是在教程中所说的:控制器与
<?php class Blog extends Controller { function index () { echo "Hello World";} } ?>
而不是有"你好世界"http://localhost/ci/index.php/blog/index/带我到完全空白的页面和http://localhost/ci/blog/index/到Apache的404未找到!顺便说一句,"http://localhost/ci/indeex.php/blog/indeex/"也把我带到空白页,但"http://localhost/ci/index.php/bloog/indeex/"-到CI的404页。你可以猜到,我对这些东西完全不熟悉,如果你能帮助我,我会很高兴的。这里有几个非常相似的问题,但它们都没有帮助。
<?php class Blog extends Controller { function index () { echo "Hello World";} } ?>
是旧版本CI(1.7?)的代码。
你运行的是什么版本?如果> 2(可能;如果您下载了当前的版本,它是2.1.0),您应该使用(注意父类名):
file controllers/blog.php
:
<?php
class Blog extends CI_Controller
{
function index()
{
echo "Hello World";
}
}
?>