一个数据库中安装多个Wordpress博客
Victor@Beijing(这里是北京!!!)
============= 一个数据库中安装多个Wordpress博客 之前, 我们分别介绍了如何在虚拟主机上面安装Wordpress 和 如何在本地安装Wordpress. 现在我们碰到了另一种情况: 买了个虚拟主机, 但是只有一个数据库, 想利用这个数据库安装多个wordpress博客. 如果你之前仔细阅读了如何在虚拟主机上面安装Wordpress , 那就简单掉渣了. 在虚拟主机的安装里面, 我们已经提到过, wp-config.php文件的数据表格前缀设置: // You can have multiple installations in one database if you give each a unique prefix $table_prefix = ‘wp_‘; // Only numbers, letters, and underscores please! 数据库是由很多数据表格组成的, 而每份数据表都可以设置一个前缀, 比如wp_posts, wp_comments. 当你要在一个相同的数据库中新建另一个Wordpress博客的时候, 唯一要注意的就是这里的表格前缀, 不要造成冲突. 比如你之前的一个博客已经使用了”wp_”来做来前缀, 那新的博客就可以使用”blog_”, “two_”等等, 只要不冲突就可以. http://paranimage.com/install-multi-wordpress-in-one-database/ ============= WordPress-一个程序多个网站的配置 这个办法在网络版和本地的情况下同样适用,之所以要讲单机版的,是因为单机版的域名配置相对麻烦,还得修改Apache跟Host文件。本人愚笨,差不多找了好几天才找到办法解决这个问题,整理了下分享一下,嘿嘿。 如果是网络版多网站一个WordPress的操作请略过前2步,直接到wp-config.php配置部分。 至于IIS服务器或Tomcat等其他服务器,咱不会……而且我相信,WordPress应该不会被安装在那些服务器下,哈哈。 好,言归正传,我们先得配置Host文件,让域名有个指向。 WIN2000和XP,Vista系统的Host文件的路径为:系统所在盘\Windows\System32\drivers\etc\下,WIN98的…自己找…… 用文本就可以打开了,在后边加上: [html] 127.0.0.2 wp 127.0.0.3 wp1 127.0.0.4 wp2 #前边是ip地址,后边是访问路径,这样我们在访问wp的时候,系统会自动解析到127.0.0.2,下边的一次类推。 #PS:后边不要输入类似于df.dou等带“.”号的东西,会被解析成互联网地址,然后就被万恶的电信带到404页面去了…… #PS2:电信的404页面有MM图… [/html] 配置完Host文件记得保存,是不是挺简单呢~ 接这配置Apache的httpd.conf,找个地方输入: [html] #由Apache来做域名的转向,D:\website\wp27all就是我们安装的WordPress的物理地址 DocumentRoot D:\website\wp27all ServerName wp DocumentRoot D:\website\wp27all ServerName wp1 DocumentRoot D:\website\wp27all ServerName wp2 [/html] 看吧,其实Apache配置起来也不难的~ 别急,还有最后一步,我们得配置下WordPress的wp-config.php文件来为各个网站分配数据库。 为了方便,这里只使用一个数据库,而使用前缀来区别不同网站。 wp-config.php: [html] /** * WordPress数据表前缀。 * * 如果您有在同一数据库内安装多个 WordPress 的需求,请为每个 WordPress 设置不同的数据表前缀。 * 前缀名只能为数字、字母加下划线。 * *如果是网络版多网站一个WordPress,把wp,wp1,wp2更换成域名即可,如http://www.nwhy.org */ if($_SERVER["HTTP_HOST"]=="wp"){ $table_prefix = 'wp_'; }else if($_SERVER["HTTP_HOST"]=="wp1"){ $table_prefix = 'wp1_'; }else if($_SERVER["HTTP_HOST"]=="wp2"){ $table_prefix = 'wp2_'; } [/html] 到此,全部搞定,现在输入http://wp开始安装第一个WordPress吧~ http://nwhy.org/wordpress-multisites.html ============= Installing Multiple Blogs Multiple Blogs Through Multiple Installs If you want multiple blogs using WordPress, you must actually install each separately (that is, as a separate WordPress installation). You can do this whether you have the ability to create multiple databases or are limited to a single database. Please note in WordPress 3.0 there is now a native ability to create multiple blogs, referred to as a network of sites. This is because the codebase for WordPressMU was merged into core. See Create A Network. http://codex.wordpress.org/Installing_Multiple_Blogs ============= Multiple WordPress Blogs, One Database by Kevin on April 22, 2009 This isn’t a new tutorial, but one that I made use of recently, as it becomes difficult to manage multiple databases for a single site, especially when you are using sub-domains and folders as extended areas of your site, rather than creating an entirely new area to your site. I’ll get into some more reasons why you would want to make use of this ability later on, but for now, I’ll start with how you achieve this. Please be aware that I am not responsible for any damages that are caused as a result of changes you make to your blog, This tutorial is simple to carry out, but could be quite difficult, if not impossible to fix if you don’t have good backups and don’t know how to edit the PHP code or file structure of your blogs/server files. 6 Easy Steps Use an FTP or folder client to view your currently installed blog. Note: If you don’t already have a blog set up, now would be a good time to do the simple setup for anew WordPress blog (creating a new database). Create an additional folder or subdomain (you may need to configure this to work properly), naming it something like blog, as it will appear as http://example.com/blog/. Find the wp-config.php file located in the location where your primary blog is hosted. Copy this file over to the folder, along with an extracted, fresh installation of WordPress (from WordPress.org). Find the line: $table_prefix = 'wp_'; // example: 'wp_' or 'b2' or 'mylogin_' of the copied over configuration file, and change the initial 'wp_' to 'blog_' as is the example above, or any other name. Go to the site with an Internet browser and go through the traditional installation steps. These tips will change the default, automatically created, new database to a line in your current table, based on the change you’ve made to the file. Reasons for Installing Multiple Blogs on One Database I didn’t really think about having to do this, as my host allows 100 MySQL Databases, but unlimited domains. It really didn’t make sense creating additional databases for folders on websites that I wasn’t planning on expanding too much. Databases that grow too large could cause problems, but many hosts can handle databases that are moderate in size, as they are mostly text – the more posts, the larger the file. Images aren’t really stored in here, but do add some size to it. The best scenario for needing this ability is if your host has a one main domain/one database limitation. While many have larger limitations, this can really limit the potential of your site, especially if you want separate areas to your site. For example, you could separate your work and personal blogs (even though this might not be the best example), nearly anything is possible without using additional resources on your server. Not everyone will want to go through these steps, especially those who are thinking about starting completely separate projects. You wouldn’t want to share multiple sites on the same database or sites that have no relation to one another. You will have a harder time backing up and restoring databases if you would choose to do this. Conclusion Getting to know the abilities of databases and some basics on using them, you will be able to extend the power of a single site. There are so many reasons for wanting to use this ability, but it isn’t taken advantage of as often as it should. As in my case, it became useful for separating content from the main page while not having to create a new database. More details can be found on the WordPress Codex. http://blogtipz.com/2009/04/22/multiple-wordpress-blogs-one-database/ =============
你的回复
回复请先 登录 , 或 注册相关内容推荐
最新讨论 ( 更多 )
- 修改WordPress主题的版权信息 (Victor@Beijing)
- phpp培训 php教程 wordpress培训 wordpress教程 免费! (大爱Ukulele)
- 让你眼睛一亮!wordpress, php, 互联网攻城师!招聘!培训!... (大爱Ukulele)
- 50+ WordPress随机插件 (Victor@Beijing)
- 文章和页面排序插件 cms tree page view 和 postmash filtered (Victor@Beijing)