使用 WordPress 设置开发、暂存和生产工作流程的好方法是什么
Wordpress 带来了一些挑战,因为它往往会在数据库中保存太多内容,从而导致服务器之间的迁移变得困难。
还有哪些其他问题需要注意?
您的工作流程是怎样的?
Wordpress presents some challenges since it tends to keep too much in the database, making it hard to move from server to server.
What are some other issues to look out for?
What was your workflow like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我设置了一个 WordPress 安装来为我的开发服务器上的多个域提供支持。插件和主题文件也是共享的,因此所有博客的升级都是一键式过程。
我使用 Apache VirtualHosts 将多个域映射到同一文档根目录,并在主
wp-config.php
中施以一点魔法,以根据当前的情况动态设置DB_NAME
主机(如果您愿意,我可以发布代码)。对于本地工作,我只有一个具有 root 权限的 MySQL 用户,并将其用于我的所有数据库(不建议在生产服务器上使用!)。
我的本地域名的命名适合真实域名,但使用了虚假的 TLD。因此,我使用
example.com
设置了一个 VirtualHostexample.dev
。当我准备好上线时,我使用 HeidiSQL 制作开发数据库的副本,然后<将所有出现的
example.dev
替换为example.com
。复制的数据库现已准备好用于生产安装。在生产服务器上镜像本地 WordPress 安装(复制插件、上传和主题),并使用 HeidiSQL(推荐)或 phpMyAdmin 导入准备好的数据库。
更新
当然,如果您对其中一个进行更改,然后将所有内容复制到另一个,那么您将丢失对另一个进行的任何更改。这不仅适用于 WordPress,也适用于生活中的几乎所有其他事物!
如果我需要在网站上线后进行重大更改(我所说的主要更改是指不应在生产服务器上进行的更改),我会执行上述相反的过程(复制从生产到开发的所有内容),进行更改,然后再次执行相反的操作。
I have a single WordPress install set up to power multiple domains on my development server. Plugin and theme files are also shared, so upgrading is a one-click process for all blogs.
I use Apache VirtualHosts to map multiple domains to the same document root, and sprinkle a little magic in the main
wp-config.php
to dynamically setDB_NAME
, based on the current host (I can post code if you like).For working locally, I just have a MySQL user with root privileges, and use it for all my databases (not recommended on a production server!).
My local domains are named appropriate to the real domains, but with a fake TLD. So working with
example.com
, I set up a VirtualHostexample.dev
.When I'm ready to go live, I use HeidiSQL to make a copy of the development database, then replace all occurrences of
example.dev
withexample.com
.The copied database is now ready for the production install. Mirror your local WordPress install on the production server (copying over plugins, uploads and themes), and use either HeidiSQL (recommended) or phpMyAdmin to import the prepared database.
UPDATE
Naturally, if you make changes to one, and then copy everything to the other, then you will lose any changes you had made on the other. This goes not just for WordPress, but for almost anything else in life itself!
If I ever need to make major changes once the site is live (and by major, I mean changes that should not be carried out on a production server), I do the reverse process of the above (copy everything from production to dev), make the changes, then do the reverse again.
WordPress.stackexchange 上提出了同样的问题并得到了解答。它包含从开发到生产快速部署的详细信息和最佳实践。
编辑
这与我在 WordPress 答案中添加的答案相同。
我可能缺少更好的方法,但我会给你两个选择:
1.使用 XML Export 导出您的新帖子和评论。然后使用 WordPress 导入器将新帖子和评论导入回开发数据库。
最好导入到开发数据库,然后将数据库移至生产环境,因为导入时会从生产环境下载所有新媒体文件。
这将解决您引入任何更改内容的问题。
2. 使用 INSERT IGNORE INTO MySql 命令从 dev 添加新表。或 REPLACE 命令覆盖同一表中的重复行。
在使用 MySql 之前,对两个数据库进行备份,并将 gz 数据库移动到生产服务器并上传转储(如果与生产相同,请更改 dev 的名称。
我对 MySql 命令不太熟悉,所以我会选择选项 1 。
This Same Question was asked and answered on WordPress.stackexchange. It contains detailed information and best practices for rapid deployment from dev to production.
Edit
This is the same answer I added at WordPress Answers.
There may be a better ways that I am missing but I am going to give you 2 options:
1.Use XML Export to export your new posts and comments. Then use the WordPress Importer to import the new posts and comments back into the dev database
It's best to import into dev then move the database over to production because when you import it will download all the new media files from production.
This would solve your problem of bringing in any changed content.
2. Use the INSERT IGNORE INTO MySql command to add the new tables from dev. or the REPLACE command to overwrite duplicate rows in the same table.
Before using MySql make a backup of both databases and move the gz database to the production server and upload the dump (change the name of dev if it's the same as production.
I'm not comfortable with MySql commands so I would go with option 1.
我的本地计算机上有开发站点,并更改本地主机文件,以便对实时服务器 (www.example.com) 的调用指向本地主机。这样,对外部文件(jquery 等)的所有调用仍然有效,我不必费心通过数据库来更改任何内容。
通过 WordPress XML 导入内容给了我最好的结果。
更新:
我使用过 http://www.mertyazicioglu.com/projects/wordpress-move/ 并取得了良好的效果。
京东
I have Development Site on my Local machine and change the local hosts file so, that calls to the live server (www.example.com) point to the localhost. That way all calls to external files (jquery, etc.) still work and I don't have to bother going through the db to change anything.
Ex- and importing the content via the wordpress XML has given me the best results.
UPDATE:
I have used http://www.mertyazicioglu.com/projects/wordpress-move/ and gotten good results.
JD
如果您安装了 phpMyAdmin,那么将 WordPress 站点从一个服务器移动到另一个服务器应该不是问题。只需将数据库导出到 tar.gz 并通过 FTP 复制您的自定义主题(如果您使用主题),然后在创建新的数据库和新的 WordPress 转储后,将它们重新上传到新服务器。对数据库中的主页和博客 URL 进行 2 处更改,对 wp-config 文件进行 2 处更改,然后就完成了。
我遇到的一件事是第三方插件。我最终自己编写了很多画廊和 javascript 小部件,因为第 3 方插件要么看起来很糟糕,要么速度很慢,要么无法按照我想要的方式工作。
感谢上帝给了 JQuery。
If you have phpMyAdmin installed moving wordpress sites from server to server should not be a problem at all. Simply export the database to a tar.gz and copy your custom theme (if your using one) via FTP and then, after creating a new DB and fresh wordpress dump, re upload both of them to the new server. 2 changes in the home and blog url in the database and 2 changes to the wp-config file and your done.
One thing I have had struggles with is 3rd party plugins. I end up coding a lot of galleries and javascript widgets myself because the 3rd party plugins either look like crap, are slow or dont work the way I want.
Thank god for JQuery.