【问题标题】:CodeIgniter 3 not working on LAMPCodeIgniter 3 无法在 LAMP 上运行
【发布时间】:2017-09-10 05:31:48
【问题描述】:

我在 MAMP 上本地运行 CodeIgniter 3 就好了。但是,当我从我的仓库中提取并尝试在安装了 LAMP 的 ec2 实例上设置它时,我得到一个 404。CodeIgniter 位于 /var/www/html 文件夹中

我的/etc/apache2/apache2.conf 文件包含以下内容:

<Directory />
    Options FollowSymLinks
    AllowOverride All
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

mod_rewrite 已启用。文件/etc/apache2/sites-available/000-default.conf如下:

<VirtualHost *:80>
    AccessFileName .htaccess
    ServerAdmin admin@yourdomain.com
    DocumentRoot /var/www/html/

    <Directory />
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    <Directory /var/www/html/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

文件/var/www/html/application/config/config.php有如下设置:

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

我的.htaccess文件如下:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

【问题讨论】:

  • 在 vhost 文件中设置服务器名称。您忘记了基本网址末尾的斜杠。它可以与 url 中的 index.php 一起使用吗?
  • 控制器(和模型)文件名以大写开头?

标签: .htaccess codeigniter virtualhost codeigniter-3


【解决方案1】:

首先检查服务器配置。您可以使用 apache 错误日志来查找与服务器相关的问题。 然后检查应用程序的错误日志。 在 database.php 中检查

    'dbdriver' => 'mysqli',

因为不支持最新的 Lamp

    'dbdriver' => 'mysql',

【讨论】:

    猜你喜欢
    • 2016-04-04
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2017-02-13
    相关资源
    最近更新 更多