【问题标题】:Apache configure ServerPath for CodeIgniterApache 为 CodeIgniter 配置 ServerPath
【发布时间】:2020-06-27 18:54:21
【问题描述】:

我对 Apache 和 CodeIgniter 非常陌生。尝试将/var/www/html 路由到http://localhost//var/www/CodeIgniterhttp://localhost/codeigniter

Apache 配置:

<VirtualHost *:80>
    ServerName localhost
    ServerPath /codeigniter
    DocumentRoot /var/www/CodeIgniter
    <Directory /var/www/CodeIgniter>
          Allowoverride All
    </Directory>
</VirtualHost>

CodeIgniter:

$config['base_url'] = 'http://localhost/codeigniter';

http://localhost/codeigniter 给了我codeigniter,但http://localhost/ 在我期望/var/www/html 时也给了我

我应该改变什么?

【问题讨论】:

    标签: php apache codeigniter


    【解决方案1】:

    您没有在您提供的 sn-p 中配置您的 DocumentRoot - 因此我们不知道您可能在提供来自 /var/www/html 的任何内容。

    我希望在您的 VirtualHost 中的某处有一个指令 DocumentRoot /var/www/html(我更喜欢在 VirtualHost 中使用这样的指令,而不是在全局服务器配置中)。从那里开始,让我们看看Apache httpd documentation

    在很多情况下需要允许网页 访问文件系统中不严格位于 DocumentRoot。 httpd 提供了几种不同的方法来实现这一点。 在 Unix 系统上,符号链接可以将 DocumentRoot 下的文件系统。出于安全原因,httpd 将 仅当相关的 Options 设置时才遵循符号链接 目录包括FollowSymLinksSymLinksIfOwnerMatch

    或者,Alias 指令将映射文件系统的任何部分 进入网络空间。例如,与

    Alias "/docs" "/var/web"

    URL http://www.example.com/docs/dir/file.html 将从 /var/web/dir/file.html.

    即我希望有一个别名来完成这项工作。

    Alias "/codeigniter" "/var/www/CodeIgniter"
    

    总而言之,更接近(这不完整/未测试):

    <VirtualHost *:80>
      ServerName localhost
      DocumentRoot /var/www/html
      Alias "/codeigniter" "/var/www/CodeIgniter"
    </VirtualHost>
    

    (添加OptionsDirectory、其他指令和权限等以品尝)

    【讨论】:

      猜你喜欢
      • 2016-09-17
      • 1970-01-01
      • 2018-11-03
      • 2017-10-23
      • 2017-09-02
      • 2016-02-26
      • 2011-10-01
      • 2014-04-11
      • 2012-08-28
      相关资源
      最近更新 更多