【问题标题】:how to move a apache localhost website to internet (i.e remote server)如何将 apache localhost 网站移动到互联网(即远程服务器)
【发布时间】:2013-03-23 10:31:41
【问题描述】:

关于将 locahost 站点移动到服务器以使其在 Internet 上可用,我几乎没有概念性疑问.....步骤是什么...服务器将如何识别我的 apache 和php 配置文件..我在 apache 2.2 上用 php 和 mysql 建立了一个网站

注意事项:

  • 我在我的 apache 配置文件中做了一些更改。其中之一是我 在 “DirectoryIndex”...所以现在我的 DirectoryIndex 看起来像:

    <IfModule dir_module>
        DirectoryIndex index.html index.php
    </IfModule>
    
  • 所以现在我的 apache 会自动告诉浏览器在调用 header('LOCATION:') 或 refresh 时搜索 index.php 文件。很明显,我的 index.php文件包含将显示或显示的 html 和其他 php 代码

  • 第三个也是最重要的...我在构建网站时在很多情况下都使用了标题功能...我的标题功能类似于header('Location: http://localhost/home/');

所以再次重复这个问题

  • 根据我的网站名称上传时我是否应该更改所有标题功能 即

    header('Location: http://www.my_site_name.com/home/'); 代替

    header('Location: http://localhost/home/');

  • 我的远程服务器将识别我在配置文件中所做的更改并根据更改工作
  • 以及将网站上传到互联网的步骤是什么

【问题讨论】:

标签: php apache web-config localhost remote-server


【解决方案1】:

谁将我的远程服务器识别我所做的更改 在我的配置文件中,并将根据更改工作

通常托管服务器配置为允许使用 .htaccess 文件覆盖 apache 配置

您可以在您的根目录中创建一个 .htaccess 文件并将您的 DirectoryIndex 设置放在那里

【讨论】:

  • 对不起..我对此知之甚少..什么是.htaccess文件..我应该写什么...以及什么的根目录????跨度>
  • 这个文件是否会帮助我的远程服务器确认我的 php 和 apache 配置文件中的更改
  • 您不能直接访问虚拟主机的 apache 配置。如果你想在你的虚拟主机上复制你的“ DirectoryIndex index.html index.php ”规则,你必须在你的站点根目录中创建一个名为 .htaccesss 的文本文件(你有你的基础 index.html 文件)。在这个文件中简单地复制 DirectoryIndex index.html index.php.
  • 同样,您不能直接访问 php.ini 文件,因此,如果您需要特定设置,则必须使用 php ini_set 函数。 php.net/manual/en/function.ini-set.php。并非所有可能的 php.ini 设置都通过 ini_set 支持。
  • .htaccess 文件和 ini_set 函数是在您没有管理权限的服务器上干扰 apache 和 php 配置的唯一方法(无法编辑 php.ini 和 httpd.conf)
【解决方案2】:

我应该在上传时更改所有标题功能吗? 我的网站名称,即header('Location: http://www.my_site_name.com/home/'); 代替header('Location: http://localhost/home/')

为什么不使用相对路径或者干脆:

header('Location: /home/');

谁将我的远程服务器识别我所做的更改 在我的配置文件中,并将根据更改工作

这样,它可以在两台服务器上运行。

以及将网站上传到互联网的步骤是什么

您应该使用 FTP 客户端将您的网站上传到您的虚拟主机。

【讨论】:

  • That way, it'll work on both servers... 远程服务器将如何理解我的“DirectoryIndex”更改
  • 所以我不需要写header('Location: http://www.my_site_name.com/home/');..right????
  • 您的DirectoryIndex 在两台服务器上都一样吗?你知道它有什么用吗? httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex
  • @SarthokBhattacharya 为什么不自己尝试一下? :)
  • DirectoryIndex 告诉 Apache 在查找给定目录的默认页面时要使用哪些文件名。我知道..我的问题是默认情况下没有 index.php..我添加了它。 ..那么远程服务器将如何理解我在 DirectoryIndex 中添加了 index.php
猜你喜欢
  • 2013-08-27
  • 2020-10-27
  • 1970-01-01
  • 1970-01-01
  • 2019-03-16
  • 2015-10-08
  • 2017-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多