Ubuntu 16.04 中的 CodeIgniter

标签 codeigniter ubuntu virtualhost

我正在尝试将我的 CI 项目从 Windows 中的本地主机移动到 Ubuntu。我正在与:

在我的 cognfig.php

$config['base_url'] = '';

$config['index_page'] = 'index.php';

我的虚拟主机:
<VirtualHost *:80>

  # Admin email, Server Name (domain name) and any aliases
  ServerAdmin mymail@mymail.com
  ServerName  mywebiml.com
  ServerAlias www.mywebiml.com


  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.php
  DocumentRoot /var/www/html/CLASE

</VirtualHost>

CI 应用程序的根文件夹是“CLASE”。
另外,我在/etc/hosts 中添加了条目
MyIp   mywebiml.com
MyIp   www.mywebiml.com

问题是,当我尝试访问我的页面时,我不断收到来自 CI 的自定义 404 错误。

最佳答案

首先你必须给 $config['base_url']一个值。使用以下

$config['base_url'] = 'http://mywebiml.com/';

其次,确保您使用的是 CI 所需的文件和类命名方案。类文件必须以类似 Ucfirst 的方式命名,而任何其他文件名(配置、 View 、通用脚本等)都应全部小写。

坏的:
some_class.php

好的:
Some_class.php

类名应始终以大写字母开头。多个单词应该用下划线分隔,而不是 CamelCased。

坏的:
class someClass {

好的:
class Some_class {

文件名和类名必须完全相同——区分大小写。

上述规则在基于 Windows 的开发环境中无关紧要,但在像 Ubuntu 这样的 linux 系统上会很重要。

如果您使用 .htaccess重写 URL,所以 index.php被删除使用以下。
$config['index_page'] = '';

关于Ubuntu 16.04 中的 CodeIgniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50609466/

相关文章:

php - Codeigniter 日历不显示正确的数据并且设置限制不起作用

ubuntu - ES 不监听外部请求

php - Apache:支持 [PHP|Python|Ruby] 的虚拟主机

php - 根据纬度/经度下载和存储谷歌街景全景图

codeigniter - url 路由在 CodeIgniter 中不起作用

php - 从 PHP 发送邮件 - 是我的错误还是邮件服务器的错误?

android - Python 脚本无法运行 "android"命令

ubuntu - 如何处理 Julia 的预编译 Linux 二进制文件?

web - 我的网站在 docker 容器中运行,如何实现虚拟主机?

macos - 如何消除 Mac OS X Lion 上本地主机/虚拟主机解析/加载缓慢(2-3 秒延迟)的问题?