Splitting One Big WordPress Site into Multiple Small Sites - php

I have a very big WordPress site and I am facing speed issue and server resources issues. Specially numbers of MySQL records are so high. So, I want to split the big WordPress site into multiple small sites.
I have URL structure like this
http://siteurl.com/this-is-first-post.html (category1)
http://siteurl.com/this-is-second-post.html (category2)
http://siteurl.com/this-is-third-post.html (category1 and category2)
I want to separate the WordPress according to category, I am thinking about two solutions
Either I create two DBs for each categories, e.g. db_cat1 and db_cat2 and I divide the data using some logic.
Or I create subdomains and install different WP instances like this:
http://category1.siteurl.com/this-is-first-post.html
http://category2.siteurl.com/this-is-second-post.html
My questions are:
If I try the first logic, then how can I divide the databases into different categories db?
If I try second logic, then how can I manage the URL structure and keep SEO juice there? How can I divide the common tags and categories?
How I will manage resources such as image etc after splitting the WordPress?
Is there any better way to do this job?
I don't want change the server or work on server because I already tried different types of server and all servers have the MySQL resources issues. I prefer second logic because it is easy to handle.

Related

Sharing Gallery Between Multiple Wordpress Sites

I'm looking for a solution that allows multiple websites to share the same table/database for just the gallery page.
The scenario is that one website will host all the images uploaded while the other website will pull images from that site and filter them to only have the ones relevant to itself. I only want to share the table/database for just the gallery images and not other posts.
Does anyone know if there is a solution that already exists for this kind of problem?
Shared databases (it's called a remote database when accessing one not on your domain/server) are possible, but they tend to get pretty hairy very quickly.
You'd be better suited to use the WP REST API to query posts (if it's a custom post type (also note if it is a custom post type, you may need to register the endpoint on the API: Read more here)) or if it's media library files, you can query media directly using http://v2.wp-api.org/reference/media/
This exact scenario is almost exactly what the v2 API was designed to deal with, and it will save you an enormous amount of stress instead of relying on two installations working on the same database.
Alternatively, you could host the images on a CDN and make queries to the CDN based on that particular site's needs.

How to handle user-created content with php?

Okay, the title isn't really explicit, my bad.
It lame title also explains why I'm probably asking a question that's already been asked - i will gladly accept other (answered) questions as an answer :)
So here's the thing:
I'm currently creating a small community website, and I was wondering how I could handle user-generated content. Everything is ready on the database side (I can store the said content) but I'm struggling on how to display individual pages for each post.
I can display a list of them, sure. But how to have one dedicated page for each content that has been generated?
Right now, I'm using controllers to render my different pages, and I can probably use them to render pages based on one entry in my database.
The thing is, I plan on integrating social elements such as a facebook 'share' or even facebook comments. I doubt I can use controllers for that in an efficient way.
So, how do you think I should proceed?
Two Methods but only one real technique.
1) Use Unique SEO URLs with htaccess (Apache System) (ie, domain.com/example/... or domain.com/test/...). htaccess separates the portions of the query string and passes it to whatever page you'd like (ie, index?id=example ).
2) Use a unique subdomains for the users. Install a wildcard subdomain *.domain.com then you can create any subdomain (example.domain.com or test.domain.com) which will still be directed to the base index page. From there you can gather the subdomain and extract the content from the database.
These are your two basic methods. 1 is the most popular standard.

How to store strings in apps that are 100% equals except the database and the strings?

I'm working in some php web apps that are almost identic, except content database, texts, and themes. Let's think in some similar like could be stackexchange sites.
The objective is mantain only one project in the same repository, so if I introduce a new feature, I only have to implement once, and not for every site.
For the themes and database is not a problem, but for the texts I don't know how can I proceed (now the texts are hardcoded in the php files).
I've googled and searched in SO, and I've find some questions similars like this where the answer was using gettext for i18n.
But in my case, it's not exactly i18n, because some of the sites are in the same language but the texts are different.
How can I store these strings?
There are tons of ways to get this done. I have a fitting project-scenario where I archive different things in different ways:
All instances of a project come from the same SVN folder.
Each instance has its own config-file, which is not included in SVN.
In addition to that, every project has its own:
Textbase (Labels, etc)
Templateset
Content
I use my own translation-system to distribute the textbase over my instances. You can use some of php's build in functions: http://verens.com/2008/04/03/translation-in-php/
The Templateset is just done by a config-variable that sets the root directory for the template-engine: ./templates/instance-x/...
The content could also referenced by a config-variable. In my case, I have a shop-system, that uses a product-base, which is used by all instances identically. To make a product available/visible to the public, you have to assign it to a category. Categories and instance-dependent.
Categories got a instance-specific ID (in my case its the shop_id).
You could for example create a table called "texts" in each database that contains the specific texts for that app. As you already have to connect with a different database for each app, you can easily implement to always get SELECT value FROM {current_database}.texts WHERE key = "headertext" or so.
That way, your code can stay the same and only the databases differ from each other.
UPDATE: And of course i18n localization is also easily implemented this way, by adding another column to the texts table containing the localization value (like en, de or nl etc.)

Multiple sites with 1 kohana core on same server

I think it has to be possible, but didn't find anything useful yet...
Is it possible to run multiple websites with from 1 Kohana core? Basically all website's are the same, only the layout is different. (Just a different view-folder, (works)) and the content is a bit different. (This is based on constant SITE_ID that pulls it from the db, (also works))
The only two things are, how do I configure this in my bootstrap/index.php? I thought of checking the url. With that url perform a query on the table 'websites' (select where url = '$url') and get the right SITE_ID and view from that query.
In that way both x.com y.com and z.com will pull up the same index.php file. After that SITE_ID is defined and with that id the right content is loaded and the right view is used.
Also, how can I do this in combination with widgets. I have like 8 different widgets and each website displays 3 of those 8 over different pages. So x.com/a will display widget 'widget_1' and 'widget_2', x.com/b will display 'widget_2' and 'widget_3'. But y.com/a has to display 'widget_6' and 'widget_7' and y.com/b has to display 'widget_3' and 'widget_4'.
Is there a way this can be managed? I didn't worked a lot with widgets before and now I want to use it in combination with multiple sites...
Possible?
For multiple sites handled via database within a single instance; what you're doing is similar to a multisite CMS. I have experience developing CMSes, both of the single site and multisite sort; I can tell you through experience that developing a multisite CMS is significantly more complex than doing multiple instances of single CMS. I usually opt for the latter if having multisite is not a requirement from the client and the implementation is up to me.
Have you considered multiple instances of websites with separate folders?
For multiple instances of single sites, I suggest reading http://kohanaframework.org/3.2/guide/kohana/tutorials/sharing-kohana to get a better idea of how do go about having multiple sites with single (or even multiple core).

Multiple Joomla websites with in One installation and database

Is it possible(out of the box) to have multiple website running on one Joomla installation.
The idea is to give clients a unique domain(or sub domain) and based on the request coming from a particular domain the view should be assembled (theme selection, articles, pages)..
Is it possible.. ??
It important that for each domain we should have a unique theme.
I am not particular about Joomla..If the same is possible with ease in any other CMS like Drupal,etc then please share your thoughts about the same.
Thanks in advance
In Drupal this is called "multisites" and it's easy to have each site have its own theme and/or even have additional modules used only on some sites, but all sites generally using the same Drupal installation. Anyway, what you describe is commonly done in Drupal and not too hard to accomplish.
More info here: http://drupal.org/documentation/install/multi-site
i am not sure about installation, but you can store all the data into a single database, but keep in mind that it is possible with multiple prefixes,
means like you have two joomla sites one with 'jos_' prefix(by default joomla prefix, you can change this) and the other with different prefix

Categories