cakephp 2 apps same file name issue - cakephp

I have 2 apps sharing the same cake core. Both apps contains similar file names for controllers and models. If debug is ON (> 0), both applications are working without any error. If it is off, whichever app I taken first in the url will work and other will show error like the method not found in the logs. I know, this is something related to cache.
Both apps have different tmp folder and I have given necessary permission. But the second app is taking looking into the tmp of first one so that app2 methods will not be there in that tmp. I checked by deleting the cache files and sometimes they are not regenerating. How to solve this issue ?
My folder structure
project folder
app1
Controller
Model
tmp
etc
app2
Controller
Model
tmp
etc
lib
cake

It is a cache issue. You most likely are using APC and did not specify unique prefix for cache config for each app. Be sure to change the default $prefix = "myapp_"' line in app/Config/core.php to unique values for each app.

Related

What files make one Wordpress site different from another

Migrating wordpress sites between hosts can take a lot of time, especially when the hosting platforms are different.
I have been trying to migrate my sites from Cpanel to Mediatemple, but it seems like im just not getting it right.
There is various options
Use the guide they provide
https://kb.mediatemple.net/questions/1556/Migrating+your+websites+to+the+Grid#gs
When moving the files in this way the permissions of the files are not set properly and I would have to got back through them and figure out which ones need to change.
The database export from PHPMyAdmin also does not look the same it looks in the screenshot
Using InfiniteWP
To use InfiniteWP you must provide the url of the site and since I dont want to change the DNS until the site is moved this option does not seems to be ideal.
This option might work if its ok for the sites to be unavailable for a day or so while the DNS resolves...
But I don't want the sites to be unavailable
Using Mediatemples "one click apps" to install wordpress and then moving only the files that are unique to the site from the old host to the new host.
I would like to use this option
I think that the content of the WP-Content folder needs to be moved that the database needs to be moved.
My question is
- what folders and files in a standard wordpress install typically hardly ever changes from one site to the other.
- can I use the wordpress database export and import function to move the database from one site to the other.
Any help will be appreciated
Thank you
With InfiniteWP, you can use the clone an existing site command (which can be found in "Tool"->"Install / Clone WP") to migrate a site to a new server.
You have to use a temporary (sub)domain pointing to the new server.
To answer your questions :
/wp-content/ stores all your files and sometimes plugin files, wp-config.php is where your configuration is stored (e.g. credentials to access the database). Depending on your servers, the .htaccess files may be different.
I would recommend to create a dump file of your entire database using phpMyAdmin.

Share one tmp folder between main domain and subdomain in cakephp

I have two domains, one is main domain and second one is subdomain. I need to share one tmp folder between both of them. In core.php i did like this define('CACHE_DIR', TMP.'cache'.DS.$_SERVER['SERVER_NAME']); and Cache::config('default', array('engine' => 'File', 'path' => ROOT.DS.'tmp'.DS)); , but its not working. Please if anybody knows about this issue, help me?
Thanks!
The TMP constant will be defined to be within the app-directory of the subdomain so you'll end up saving the files whitin
/subdomain-path/app/tmp/cache/domainname
The TMP constant is defined inside bootstrap.php, but you can override it by defining it yourself inside your index.php
If you set the TMP to the right location, all temp, session and cache files will be written to that location. So consider it is a problem if session-data is stored in the shared directory
important
Be sure to set a different cache $prefix for each website. Otherwise Models cached for one website will also be used by the other website, which may cause data from the wrong database to be used!! This variable can be set inside your app/Config/core.php
important2
I would strongly advise you to not use the $_SERVER['SERVER_NAME'] variable. If your website uses serverAliases (e.g. both handles www.example.com and example.com) then a separate cache-directory will be used for both (sub)domains. It's best to set a fixed path.
One solution would be to set up a symbolic link from the subdomains tmp folder to the main domains tmp folder.
http://www.tech-recipes.com/rx/172/create_a_symbolic_link_in_unix_solaris_linux/
Then the subdomain app can just treat the tmp folder as any normal app would.
There may be a special cake way to do it but this should work just as well :)

Cake php host in server with multiple domain

I have a server with many domains/ applications on it. I need to host a cake php application on that server. When I uploaded, I get errors w.r.t urls.
for eg, www.xyz.com/aboutus. this url is working. there is a controller called Aboutus.
But when I take the url www.xyz.com/aboutus/add, it must go to the add method in Aboutus controller. It is working in my local system. But in live, it shows the error that 'add' controller is missing.
In my local, I have changed the document root in apache. But in live server I cant do this as there are multiple sites.
You need to make sure that the ROOT, APP_DIR, and CAKE_CORE_INCLUDE_PATH variables in each site's webroot/index.php have been updated to go to the right paths. [details here] (or see below where I list my settings) Other than that, just make sure your host has mod rewrite on and you should be good to go.
According the the CakePHP book for 2.0.x, it's easier to just change the include_path, but I haven't tried that yet: http://book.cakephp.org/2.0/en/deployment.html#multiple-cakephp-applications-using-the-same-core
The file-structure I use:
/cakephp
/cakephp_1_3
/cakephp_2_0_5
/public_html
/mysite1.com
/mysite2.com
/mysite3.com
//webroot/index.php (of one of my sites)
define('ROOT', DS.'home'.DS.'myusername'.DS.'public_html');
define('APP_DIR', DS.'mysite1.com');
define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'myusername'.DS.'cakephp'.DS.'cakephp_2_0_5'.DS.'lib');
(I just took the 3 lines that set the variables - they're not really three lines in a row like that)
Don't forget to make sure your database settings are still correct in app/Core/Config/database.php

CakePHP - Get my application root address from model

I am looking to get http://www.mysite.com/app_directory in the model. Note my app is not in the site root. I need it to perform a cURL request and I don't want to hard code it because the app location will change. I also need the check to return http://www.mysite.com if the app moves to the site root.
About it being a bad idea to have the model know about its environment, I was wanting to check if a URl is an external web page or a URl within the current website.
that would do:
env('HTTP_HOST')
it's cake way of looking at:
$_SERVER['HTTP_HOST']

CakePHP: Shared Hosting Dilemma

I'm having trouble with uploading my cakePHP project on a shared hosting ( from hostgator ).
Here is what I have done:
I've organized my cake distribution like this:
home/user/app
home/user/cake/cake
home/user/cake/vendors
home/user/cake/.htaccess
home/user/cake/index.php
I have taken the content of webroot directory from app and put it in
home/user/public_html
I've modified this file home/user/public_html/index.php ( the one that was in app/webroot )
changing these lines like this:
define('ROOT', DS.'home'.DS.'user');
define('APP_DIR', 'app');
define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'user'.DS.'cake');
And that's about it.
MY PROBLEM IS THE FOLLOWING:
I have managed to deal with all the problems involved in the default index.php cakePHP page and I have a green and fully functional so to say, project. So when I access my "/", I get:
"Your tmp directory is writable.
The FileEngine is being used for caching. To change the config edit APP/config/core.php
Your database configuration file is present.
Cake is able to connect to the database."
Now, I've created a model-view-controller with a mysql database background (like in the 15 min Blog Tutorial ), but when I'm trying to access some views ( e.g. /posts )...it gives me a blank page ( this worked perfect on my local machine virtual server apache ).
What configuration am I missing ?
Thank you.
EDIT: Apparently I had problems with the hosting. My URL was something like:
http://gator111.hostgator.com/~username/
and all I had to do was add an extra line in the webroot .htaccess:
RewriteBase /~username/
Thanks for the support.
This tutorial is a life saver, I had the same problem that my host name comes with ~username. Now after adding the 'rewriteBase /~username/', works like a charm.
However, before all these, I followed a youtube tutorial by jason talking about how to configure cakephp on shared hosting. Just paste it here in case it helps anybody.
http://www.youtube.com/watch?v=4GobWo1rIkE&tracker=False

Resources