项目迁移到不同的服务器

编程入门 行业动态 更新时间:2024-10-25 23:29:41
本文介绍了项目迁移到不同的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

您好, 我们正在开发一个客户项目,整个网站都在我们的服务器上。完成后,我们将项目迁移到他们的服务器,但现在每篇文章都包含奇怪的字符,如 - > ? ? 我不确定,会出现什么问题。它在我们的服务器中非常好,但在客户端服务器中显示所有这些字符。 我们使用的是UTF8字符集。 如果你能想到任何一个,请告诉我。解决它。 谢谢

Hello, We were working on one of our clients project and the whole site was on our server. After completion, we migrated ths project to their server but now every articles contain weird characters like -> ?���?��2 I am not sure, what can go wrong. It's perfectly fine in our server but showing all this characters in client server. We are using UTF8 character set. Please let me know, if you can think of any solution to it. Thanks

推荐答案

如果从一个服务器迁移到另一个服务器并且文章具有不正确的编码几率它们的存储方式配置不正确。我最近从一个网站复制内容并将其粘贴到运行在Windows服务器上的Notepad ++中,我通过RDP访问该服务器并运行一些编码问题,这些问题使得任何脚本都能运行。错误看起来与此类似: If migrating from one server to another and 'articles' have improper encoding odds are the means by which they are stored isn't configured correctly. I was recently copying content from a website and pasting it in to Notepad++ running on a Windows server through which I was accessing via RDP and ran in to some encoding issues that nuked the ability for any scripts to run. Errors looked similar to this: Notice: Use of undefined constant    - assumed '   ' in E:\www.snmp\public_html\test2.php on line 4

这意味着Apache中的字符编码被解释错误,并通过在httpd.conf中添加以下内容来解决这个问题

Which means the character encoding was being interpreted wrong by in Apache and was remedied by adding the following to httpd.conf

AddDefaultCharset UTF-8

但是在你的情况下,我想它实际上不是PHP文件,正如你所说'文章'看起来全部奇怪的是,这只是内容的编码不正确。您可以使用PHP声明文档编码

However in your case I imagine it's not actually the PHP files as you said 'articles' look all strange suggesting it's just content that's improperly encoded. You can declare document encoding with PHP

<?php header('Content-type: text/html; charset=utf-8'); ??>

如果文章内容来自MySQL - 您可以使用类似的内容您的代码可能是您问题的解决方案。

and if the article content is coming from MySQL - you can use something like this in your code which is likely the solution to your problem.

mysqli-> set_charset( utf8) mysqli->set_charset("utf8")

那是假设很多但只是简单地说 - 如果编码问题出现在您传输的文件中,那么PHP本身很可能无法正常运行,但如果它位于站点内容中,那么您的数据库或其他存储介质可能无法正确配置。如果您在应用程序中创建并保存新内容时显示傻瓜,则问题在于在存储内容时将一个字符集转换为另一个字符集。无论哪种方式:只需在整个服务器配置中验证字符编码的一致配置即可。您的开发环境与其生产环境之间。

That's assuming a lot but simply put - if the encoding issue is in the files you transferred there's a good chance PHP itself wouldn't function properly however if it's in the content of the site then your DB or other storage medium may not be properly configured. If when you create and save new content within your app it displays goofy then the issue lies somewhere in the conversion of one character set to another while storing the content. Either way: it's all just a matter of verifying the consistent configuration of character encoding throughout your server's configuration & between your dev environment and their production environment.

更多推荐

项目迁移到不同的服务器

本文发布于:2023-11-28 12:54:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642487.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   项目

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!