【问题标题】:is "root web server" the same as localhost? installing CodeIgniter“根网络服务器”与本地主机相同吗?安装 CodeIgniter
【发布时间】:2013-09-17 13:20:48
【问题描述】:

我正在尝试安装 CodeIgniter(我有 Mac)。我没有使用框架的经验,但我读过一些关于 MVC 的内容。我的目标是设置 CodeIgnitor,以便我可以使用它。

所以我下载了 CodeIgniter,然后在一个教程中告诉我以下内容:将文件复制到服务器的 Web 根文件夹,通常是 /var/www/ !

在本教程中:http://www.phpeveryday.com/articles/CodeIgniter-Introduction-to-CodeIgniter-Framework-P147.html

我被告知“打开您的根网络服务器”并将文件夹放入其中。

什么是“根网络服务器”?是我的 htdocs 吗?我应该把这个文件夹放在哪里?

我将文件夹放入我的 HTDOCS 文件夹,因为这是所有 PHP 文件所在的位置,但我不确定我是否做得对。

【问题讨论】:

  • 如果您有 Apache,htdocs 是典型的 Web 根文件夹。

标签: php macos codeigniter


【解决方案1】:

请安装世界上最简单的东西XAMPP

找到文件夹xampp/htdocs(所需的Web根文件夹)并在其中创建文件夹(项目名称),在那里解压缩/unrar/un7z CI,这样您的文件夹结构将是

xampp/htdocs/project_name/application
                         /system
                         /index.php

打开project_name/application/config 并逐一查看所有文件,这样您就知道CI 可以做什么和不可以做什么,每个文件中都很好地解释了每个设置的作用。

如果您是 CI,请关注video tutorial


如果您正在寻找好的.htaccess 文件,请抓住这个并根据您的需要进行更改

注意:这个文件应该在 /project_name

注意2:同样在config/config.php 中将index_page 设置为$config['index_page'] = '';

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /<your project name>

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

更改.htaccessconfig/config.php 后,您的网址“不错” localhost/project_name/controller/method/parameter1/parameter2

最后:是 CodeIgniter 而不是 CodeIgnitor

【讨论】:

    猜你喜欢
    • 2017-07-30
    • 2015-10-11
    • 2019-07-15
    • 1970-01-01
    • 1970-01-01
    • 2013-01-24
    • 1970-01-01
    • 2011-08-07
    • 2015-05-17
    相关资源
    最近更新 更多