Moving PHP site from one server to another

寵の児 提交于 2021-02-07 10:22:25

问题


I have no idea about PHP.

I have PHP site hosted on Server A. Now I want to transfer the hosting to another company having Windows hosting on Server B.

Can I just transfer all the contents of WWWROOT folder of Server A to Server B? Will the site work that way? Or I do have to get the source, compile and publish it?

Thanks!


回答1:


the process is this:

  1. copy the content from server A to B (also db dump)
  2. make sure your site is working on server B correct
  3. set a redirect on server A to server B (usually in .htaccess file)
  4. edit DNS entries to point to server B
  5. wait that DNS changes have been picked up (note: as suggested by Emil you can reduce this time by lowering TTL setting on the DNS entries)
  6. remove content from server A (end hosting)



回答2:


PHP is not (usually) compiled, you should be able to simply copy the files and directories over and they should at least run. You may have to set up a database and connections to it, change some configuration in the scripts and you may or may not run into incompatibilities between different PHP versions and/or UNIX/Windows problems though, depending on how portable the scripts were written.




回答3:


you don't need to compile anything. it's enough to copy project directory from one server to another. one thing can cause your project not working on ohter hosting, if there will not be installed some php-extensions that are required for you project. and of course, if your project uses some databases, they must be created on new server




回答4:


PHP scripts are source code and are compiled when needed. Simply moving the files is enough. Problems may occur if it is a package that has been isntalled on that server and may have some properties in various files about absolute paths to other files.

Also, issues will occur if the files are talking to a local SQL server or the such.

Many hosting companies offer a free (or sometimes payed) service to copy your website accross including any databases. Ask your hosting company for help.




回答5:


No need to compile, however you have to make sure that the new server meets all the requirements of your application (e.g. server modules) and that paths are correctly configured. Also under some circumstances the PHP version can matter as well. Only one way to find out!



来源:https://stackoverflow.com/questions/5988193/moving-php-site-from-one-server-to-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!