简体   繁体   English

本地计算机上的Web服务器,有任何陷阱吗?

[英]Web server on local machine, are there any gotchas?

如果由于尚未托管而使用xampp或其他软件在PC上设置了本地“网络服务器”,我是否应该期望某些可以在网络上运行的html,javascript或php代码无法在本地Web服务器,还是实际上与实际Web服务器相同的测试环境?

If your code interacts with the host system (manipulating files and directories, running OS commands) or with other programs (like mailer), there are chances that things will break when you move from your windows machine to a real hosting (which will most probably be linux). 如果您的代码与主机系统(操纵文件和目录,运行OS命令)或与其他程序(如邮件程序)交互,则当您从Windows计算机迁移到真实主机时,事情有可能会中断(这很可能会发生)是linux)。 Also, if you use any non-standard php modules, getting them running on windows could be troublesome. 另外,如果您使用任何非标准的php模块,则使它们在Windows上运行可能会很麻烦。

Installing a virtual machine with linux and running web/db servers in their native environment might be a better option than xammp or similar tools. 与xammp或类似工具相比,在Linux上安装虚拟机并在其本机环境中运行Web / db服务器可能是更好的选择。 This config is more difficult to set up, but more convenient and flexible in the long run. 此配置较难设置,但从长远来看更方便灵活。 Popular VM runners are VirtualBox, Parallels and VMWare - google them up. 最受欢迎的VM赛跑者是VirtualBox,Parallels和VMWare-用Google搜索它们。

Make sure that you are running the same version of services that your hosting provides. 确保您运行的是托管服务所提供的相同版本的服务。 This will help you: http://www.host-shopper.com/basic-web-hosting-options.html 这将为您提供帮助: http : //www.host-shopper.com/basic-web-hosting-options.html

One big difference is the OS specific directory structure; 一大区别是操作系统特定的目录结构; I use a windows computer but LAMPP on a linux server, so I have to keep those differences in mind. 我使用Windows计算机,但在Linux服务器上使用LAMPP,因此我必须牢记这些差异。

On my PC webroot is 在我的PC上,webroot是

 C:\xampp\htdocs

On my XAMMP linux box webroot is 在我的XAMMP linux机器上,webroot是

/opt/lampp/htdocs

but on my apache linux boxes webroot is either 但在我的Apache Linux机器上,webroot是

/var/www/

or 要么

/var/www/html/

These settings typically reflect defaults, they can be changed in your server config, but that would be a big gotcha as far as trying to just dump some local code on a server, any absolute path references might just crash and burn. 这些设置通常反映默认值,可以在您的服务器配置中进行更改,但是就尝试将某些本地代码转储到服务器上而言,这将是一个很大的难题,任何绝对路径引用都可能崩溃和刻录。

Main issue I can think of would be subdomains on localhost, but you should be all set for now. 我能想到的主要问题是localhost上的子域,但是现在您应该已全部设置。

BTW, once you get it setup, I recommend checking out GitHub so if you ever break your site you can revert back. 顺便说一句,一旦安装完成,我建议您检查GitHub,以便在中断站点后可以恢复使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 访问客户端本地网络上的文件,但不能从 Web 服务器访问本地计算机 - Access files on clients local network but not local machine from web server 是否有任何网络浏览器插件可以访问机器的命令行? (供本地使用) - Are there any web browser plugins that can give access to machine's command line? (for local use) 通过网页与本地计算机进行通信 - Communicate with the local machine from a web page CSS for JS按钮可在本地计算机上运行,​​但不能在服务器上运行 - CSS for JS button works on Local machine but not server JavaScript的; 本地计算机(无服务器); 访问iFrame内容 - Javascript; local machine (no server); access iFrame content 如何浏览目录服务器计算机而不是本地计算机 - How to browse directory server machine instead of local machine Tomcat servlet 在本地机器上工作,在服务器上中断 - Tomcat servlet works on local machine, breaks on server Web SQL无法从本地文件系统运行,如何在没有任何服务器的情况下运行? - Web SQL not working from local file system, how can I run without any server? 有什么方法可以在不运行服务器软件的情况下通过网页编辑本地文件? - Is there any way to edit a local file through a web page without running server software? 任何使用typeof window.postMessage === undefined的陷阱? - Any gotchas using typeof window.postMessage === undefined?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM